QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#660222 | #9427. Collect the Coins | liuziao | WA | 0ms | 3604kb | C++23 | 1.5kb | 2024-10-20 09:14:35 | 2024-10-20 09:14:37 |
Judging History
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;
}
詳細信息
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'