Submission #976620

#TimeUsernameProblemLanguageResultExecution timeMemory
976620LucaIlieThe Big Prize (IOI17_prize)C++17
20 / 100
50 ms2136 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; const int MAX_N = 2e5; int ans[MAX_N][2]; bool found = false; int pos; pair<int, int> askk( int i ) { if ( ans[i][0] == -1 ) { auto x = ask( i ); ans[i][0] = x[0]; ans[i][1] = x[1]; } if ( ans[i][0] + ans[i][1] == 0 ) { found = true; pos = i; } return { ans[i][0], ans[i][1] }; } void solve( int l, int r ) { if ( found ) return; if ( l > r ) return; int bs = sqrt( r - l + 1 ); int f = (l == 0 ? 0 : askk( l - 1 ).first ); if ( found ) return; for ( int lb = l; lb <= r; lb += bs ) { int rb = min( r, lb + bs - 1 ); int g = askk( rb ).first; if ( found ) return; if ( g - f > 0 ) { solve( lb + 1, rb - 1 ); if ( found ) return; } } } int find_best( int n ) { for( int i = 0; i < n; i++ ) ans[i][0] = ans[i][1] = -1; solve( 0, n - 1 ); return pos; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...