Submission #599259

#TimeUsernameProblemLanguageResultExecution timeMemory
599259Ahmadsm2005The Big Prize (IOI17_prize)C++14
90 / 100
99 ms300 KiB
#include<bits/stdc++.h> #include "prize.h" //#include "grader.cpp" using namespace std; vector<int>GLOB; int find_best(int n){ int CNT=0; for(int i=0;i<min(n,500);i++){ vector<int>R=ask(i); CNT=max(CNT,R[0]+R[1]); } int FOUND=0,LAST=0; while(1){ int L=LAST,R=n-1,mid,BEST=-1; while(1){ vector<int>z=ask(L); if(z[0]+z[1]==0) return L; if(z[0]+z[1]!=CNT) L++; else{ FOUND=z[0]; break; } } while(L<=R){ mid=(L+R)/2; vector<int>z=ask(mid); int A=z[0],B=z[1]; if(!A&&!B) return mid; else if(A+B!=CNT){ BEST=mid; R=mid-1; } else if(A>FOUND) R=mid-1; else L=mid+1; } if(BEST==-1) exit(1); LAST=BEST+1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...