# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
790797 | peteza | The Big Prize (IOI17_prize) | C++14 | 4 ms | 432 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 <bits/stdc++.h>
#include "prize.h"
using namespace std;
bool vis[200005];
int find_best(int n) {
if(n == 1) return 0;
int mx = -1, ci;
int c0, c1;
for(int i=0;i<min(n, 500);i++) {
auto e = ask(i);
if(e[0] + e[1] > mx) {
c0 = e[0], c1=e[1];
mx = e[0] + e[1]; ci = i;
}
}
//start at ci
int cl = ci, l, r, mid;
while(1) {
l = ci; r = n-1;
int n0, n1;
while(l<=r) {
mid = (l+r) >> 1;
auto e = ask(mid);
if(e[0] + e[1] != mx) r = mid-1;
else if(e[0] == c0) l = mid+1;
else r = mid - 1;
}
//if(ci != 2)
//cout << ci << ' ' << l << '\n';
for(int i=ci;i<l;i++)
vis[i] = 1;
ci = l; auto e = ask(ci);
while(ci < n && e[0] + e[1] != mx) {
if(ci >= n-1) break;
e = ask(++ci);
c0 = e[0]; c1 = e[1];
}
if(ci >= n-1) break;
}
for(int i=0;i<n;i++) {
if(vis[i]) continue;
auto e = ask(i);
if(e[0] + e[1] == 0) return i;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |