# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
960657 | MarwenElarbi | The Big Prize (IOI17_prize) | C++17 | 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;
std::vector<int> ask(int i);
int find_best(int n){
int bg=0;
int cnt=0;
/*for (int i = 0; i < min(480,n); ++i)
{
vector<int> cur=ask(i);
if(cur[0]==0&&cur[1]==0) return i;
if(cnt<=cur[0]+cur[1]){
cnt=max(cnt,cur[0]+cur[1]);
bg=i;
}
}*/
while(true){
//return 0;
int l=bg;
int r=n;
//cout <<l<<endl;
vector<int> fir=ask(l);
if(fir[0]==0&&fir[1]==0) return l;
while(r-l>1){
int mid=(r+l)/2;
vector<int> cur=ask(mid);
if(cur[0]==0&&cur[1]==0) return mid;
if(cur[0]==0) l=mid;
else if(cur[0]+cur[1]!=cnt){
r=mid;
continue;
}
else if(cur[1]+fir[0]!=cnt) r=mid;
else {
l=mid;
}
}
bg=l+1;
while(vis[bg]) bg++;
fir=ask(bg);
if(fir[0]==0&&fir[1]==0) return bg;
while(fir[0]+fir[1]!=cnt){
bg++;
if(vis[bg]) continue;
fir=ask(bg);
if(fir[0]==0&&fir[1]==0) return bg;
}
}
return n-1;
}