# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
282908 | turbat | The Big Prize (IOI17_prize) | C++14 | 0 ms | 0 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;
int find_best(int n) {
int l, r, mx = -1e9, mid;
for (int i = 0;i < min(10, n);i++){
int ind = rand() % n;
vector<int> res = ask(ind);
if(res[0] + res[1] == 0)
return i;
mx = mx(mx, ask([i]))
}
for(int i = 0; i < n; i++){
vector<int> res = ask(i);
if(res[0] + res[1] == 0)
return i;
mx = max(mx , res[0]+res[1]);
if((res[0]+res[1]) < mx) continue;
l = i + 1;
r = n - 1;
while(l <= r){
ll mid = (l+r)/2;
vector<int> tmp=ask(mid);
if(tmp[0]+tmp[1]==0)return mid;
if(tmp == res){
i = mid;
l = mid+1;
}
else r = mid-1;
}
}
}