Submission #59001

#TimeUsernameProblemLanguageResultExecution timeMemory
59001tugushkaThe Big Prize (IOI17_prize)C++14
97.31 / 100
73 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, low = 0; sq = sqrt(n); /* for( ; now < min(sq+30, n-1) ; now++ ){ res = ask(now); x[now] = res; cnt[res[0]+res[1]]++; mx = max( res[0]+res[1], mx ); if( res[0] == 0 && res[1] == 0 ) return now; } for( map < int, int > :: iterator it = cnt.begin() ; it != cnt.end() ; it++ ){ if( it -> first != mx ) low += it->second; } */ 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+1, r = min(n-1, now + 3*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; }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:11:15: warning: unused variable 'low' [-Wunused-variable]
  int now = 0, low = 0;
               ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...