Submission #1029230

#TimeUsernameProblemLanguageResultExecution timeMemory
1029230amirhoseinfar1385The Big Prize (IOI17_prize)C++17
90 / 100
193 ms1492 KiB
#include "prize.h" #include<bits/stdc++.h> using namespace std; map<int,pair<int,int>>mp; int cnta=0; pair<int,int>pors(int u){ if(mp.count(u)==0){ cnta++; if(cnta>=10000){ exit(23); } vector<int>hey=ask(u); mp[u]=make_pair(hey[0],hey[1]); } return mp[u]; } int find_best(int n) { mp.clear(); int cnta=0; int wtf=-1; for(int i=0;i<n;){ //cout<<i<<endl; pair<int,int>av=pors(i); if(av.first+av.second==0){ return i; } cnta++; pair<int,int>fake; if(wtf!=-1){ fake=pors(wtf); if(av.first+av.second<=fake.first+fake.second){ i++; continue; } } int low=i,high=n,mid,f=0; for(auto x:mp){ mid=x.first; fake=pors(mid); if(fake.first+fake.second!=av.first+av.second){ if(fake.first+fake.second>av.first+av.second){ f=1; break; } high=mid; }else{ if(fake.first-av.first==0){ low=mid; high=n; }else{ high=mid; } } } if(f){ wtf=i; i=low+1; continue; } low=max(low,i); while(high-low>1){ mid=(high+low)>>1; fake=pors(mid); if(fake.first+fake.second!=av.first+av.second){ if(fake.first+fake.second>av.first+av.second){ wtf=i; break; } high=mid; }else{ if(fake.first-av.first==0){ low=mid; }else{ high=mid; } } } i=low+1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...