Submission #317371

#TimeUsernameProblemLanguageResultExecution timeMemory
317371tigichaThe Big Prize (IOI17_prize)C++14
90 / 100
108 ms512 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...