QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#660222#9427. Collect the CoinsliuziaoWA 0ms3604kbC++231.5kb2024-10-20 09:14:352024-10-20 09:14:37

Judging History

你现在查看的是最新测评结果

  • [2024-11-06 15:56:27]
  • hack成功,自动添加数据
  • (/hack/1139)
  • [2024-10-20 09:14:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2024-10-20 09:14:35]
  • 提交

answer

#include <bits/stdc++.h>

// #define int int64_t

const int kMaxN = 1e6 + 5;

int n;
std::pair<int, int> a[kMaxN];

int getk(int i, int j) {
  if (i > j) std::swap(i, j);
  int d = a[j].first - a[i].first;
  if (a[i].first == a[j].first) return a[i].second == a[j].second ? 0 : 2e9;
  else return (abs(a[i].second - a[j].second) + d - 1) / d;
}

bool check(int v) {
  static bool vis[kMaxN];
  int id[2] = {0};
  std::vector<int> vec[2];
  for (int i = 2; i <= n; ++i) {
    vis[i] = 0;
    if (getk(i - 1, i) > v) vis[i] = 1;
  }
  int col = 0;
  vec[0].emplace_back(1);
  for (int i = 2; i <= n; ++i) {
    if (vis[i]) col ^= 1;
    vec[col].emplace_back(i);
  }
  for (int i = 1; i < (int)vec[0].size(); ++i)
    if (getk(vec[0][i - 1], vec[0][i]) > v)
      return 0;
  for (int i = 1; i < (int)vec[1].size(); ++i)
    if (getk(vec[1][i - 1], vec[1][i]) > v)
      return 0;
  return 1;
}

void dickdreamer() {
  std::cin >> n;
  for (int i = 1; i <= n; ++i) std::cin >> a[i].first >> a[i].second;
  std::sort(a + 1, a + 1 + n);
  int L = -1, R = 1e9, res = 1e9;
  while (L + 1 < R) {
    int mid = (L + R) >> 1;
    if (check(mid)) R = res = mid;
    else L = mid;
  }
  std::cout << res << '\n';
}

int32_t main() {
#ifdef ORZXKR
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
  int T = 1;
  // std::cin >> T;
  while (T--) dickdreamer();
  // std::cerr << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3604kb

input:

3
5
1 1
3 7
3 4
4 3
5 10
1
10 100
3
10 100
10 1000
10 10000

output:

0

result:

wrong answer 1st lines differ - expected: '2', found: '0'