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>
using namespace std;
vector <int> v;
int mx, k, p, l, r, m, ans;
int find_best(int n){
for(int i=0; i<474;i++){
v=ask(i);
if(v[0]+v[1]==0) return i;
if(v[0]+v[1]>mx){
mx=v[0]+v[1];
k=i;
p=v[0];
}
}
while(true){
l=k+1;
r=n-1;
while(l<=r){
m=(l+r)/2;
v=ask(m);
if(v[0]+v[1]==0) return m;
if(v[0]+v[1]==mx && v[0]==p) l=m+1;
else r=m-1;
if(v[0]+v[1]!=mx) ans=m;
}
for(int i=ans; i<n; i++){
v=ask(i);
if(v[0]+v[1]==0) return i;
if(v[0]+v[1]==mx){
k=i;
p=v[0];
break;
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |