Submission #58990

#TimeUsernameProblemLanguageResultExecution timeMemory
58990tugushkaThe Big Prize (IOI17_prize)C++14
96.75 / 100
65 ms1212 KiB
#include "prize.h" #include<bits/stdc++.h> using namespace std; vector < int > res, a; map < int, vector < int > > x; map < int , int > cnt; int sq, mx; int find_best(int n){ int now = 0; sq = sqrt(n); while( 1 ){ if( x[now].empty() ) res = ask(now); else res = x[now]; x[now] = res; mx = max(mx, res[0]+res[1]); if( res[0] == 0 && res[1] == 0 ) return now; if( res[0]+res[1] == mx ){ int l = now, r = min(n-1, now+2*sq); while( l < r ){ int mid = (l+r+1)/2; if( x[mid].empty() ) a = ask(mid), x[mid] = a; else a = x[mid]; if( !a[0] && !a[1] ) return mid; if( res[0] == a[0] && res[1] == a[1] ) l = mid; else r = mid-1; } now = l+1; } else now++; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...