记录编号 601480 评测结果 AAAAAAAAAA
题目名称 1722.[WC 2002] 奶牛浴场 最终得分 100
用户昵称 GravatarLikableP 是否通过 通过
代码语言 C++ 运行时间 0.253 s
提交时间 2025-06-24 21:15:15 内存使用 1.41 MiB
显示代码纯文本
#include <algorithm>
#include <cstdio>
#define isdigit(ch) ((ch) >= '0' && (ch) <= '9')

namespace IO {
template <typename T>
T read() {
  T res = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-')
      f = -1;
  for (; isdigit(ch); ch = getchar())
    res = (res << 3) + (res << 1) + (ch ^ 48);
  return res * f;
}

template <typename T>
void write(T x, char ed = '\n') {
  if (x < 0)
    x = -x, putchar('-');
  int sta[sizeof(T) << 2], top = 0;
  do {
    sta[++top] = x % 10;
    x /= 10;
  } while (x);
  while (top) {
    putchar(sta[top--] ^ 48);
  }
  putchar(ed);
}
} // namespace IO
using namespace ::IO;

const int MAXN = 5010;

struct COW {
  int x, y;
} a[MAXN];

int L, W;
int n;
int ans = -1;

int main() {
  freopen("wc2002_happy.in", "r", stdin);
  freopen("wc2002_happy.out", "w", stdout);
  L = read<int>(), W = read<int>();
  n = read<int>();
  a[1] = {0, 0};
  n++;
  for (int i = 2; i <= n; ++i) {
    a[i].x = read<int>(), a[i].y = read<int>();
  }
  a[++n] = {L, 0};

  ::std::sort(a + 1, a + n + 1, [](COW x, COW y) {
    if (x.x != y.x)
      return x.x < y.x;
    return x.y < y.y;
  });

  for (int i = 1; i <= n; ++i) {
    int U = W, D = 0;
    for (int j = i + 1; j <= n; ++j) {
      ans = ::std::max(ans, (a[j].x - a[i].x) * (U - D));
      if (a[j].y >= a[i].y)
        U = ::std::min(U, a[j].y);
      if (a[j].y <= a[i].y)
        D = ::std::max(D, a[j].y);
    }
  }

  write(ans);
  return 0;
}