# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1118405 | adaawf | The Big Prize (IOI17_prize) | C++17 | 38 ms | 704 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
using namespace std;
int a[20005], cc = 0;
vector<int> ask(int i);
int find_best(int n) {
vector<pair<int, pair<int, int>>> v;
vector<int> t;
int mi = 0;
for (int i = 1; i <= 480; i++) {
t = ask(i);
if (t[0] + t[1] == 0) return i;
mi = max(mi, t[0] + t[1]);
}
int c = 0;
for (int i = 1; i <= 20000; i += 10) {
c = 0;
while (1) {
if (i > n) break;
t = ask(i);
if (t[0] + t[1] == 0) return i;
if (t[0] + t[1] == mi) {
break;
}
c++;
i++;
}
if (i <= n) v.push_back({i, {t[1], c}});
}
//cout << cc << '\n';
v.push_back({n + 1, {0, c}});
for (int i = 0; i < v.size() - 1; i++) {
int h = v[i].second.first - v[i + 1].second.first;
h -= v[i + 1].second.second;
if (h >= 2) {
for (int j = v[i].first + 1; j < v[i].first + 10; j++) {
t = ask(i);
if (t[0] + t[1] == 0) return j;
}
}
else if (h == 1) {
int l = v[i].first + 1, r = v[i].first + 9, res;
while (l <= r) {
int mid = (l + r) / 2;
t = ask(mid);
if (t[0] + t[1] == 0) return mid;
if (t[0] + t[1] != mi) break;
if (t[1] == v[i].second.first) {
res = mid;
l = mid + 1;
}
else r = mid - 1;
}
}
}
return -1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |