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 maxx,idx,l,le,ri,mid,ans;
int find_best(int n) {
for(int i=0;i<500;i++) {
v=ask(i);
if(v[0]+v[1]==0) return i;
if(v[0]+v[1]>maxx) {
maxx=v[0]+v[1];
idx=i;
l=v[0];
}
}
while(true) {
le=idx+1; ri=n-1;
while(le<=ri) {
mid=(le+ri)/2;
v=ask(mid);
if(v[0]+v[1]==maxx && v[0]==l) le=mid+1;
else { ri=mid-1; }
if(v[0]+v[1]!=maxx) ans=mid;
}
for(int i=ans+1;i<n;i++) {
v=ask(i);
if(v[0]+v[1]==0) return i;
if(v[0]+v[1]==maxx) {
idx=i;
l=v[0];
break;
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |