# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
132681 | Talant | The Big Prize (IOI17_prize) | C++17 | 82 ms | 504 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 "prize.h"
#include <bits/stdc++.h>
#define sc second
#define fr first
#define mk make_pair
#define pb push_back
using namespace std;
const int N = (1e6 + 5);
const int inf = (1e9 + 7);
int find_best(int n) {
int cur = 0;
int cn = 0;
int cnt = 0;
while (1) {
int l = cur,r = n - 1;
vector<int> res = ask(cur);
cnt ++;
if (cnt > 10000) {
assert(0);
}
if (res[0] + res[1] == 0) return cur;
cn = res[0];
while (r - l > 1) {
int m = (r + l) >> 1;
res = ask(m);
cnt ++;
if (cnt > 10000) {
assert(0);
}
if (res[0] + res[1] == 0) return m;
if (res[0] == cn) l = m;
else r = m;
}
res = ask(r);
cnt ++;
if (cnt > 10000) {
assert(0);
}
if (res[0] + res[1] == 0) return r;
if (res[0] == cn) l = r;
cur = l + 1;
if (cur > n - 1) break;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |