#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);
for( ; now < min(sq+30, n-1) ; now++ ){
if( x[now].empty() ) res = ask(now);
else res = x[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;
}
int low = 0;
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, r = min(n-1, now+sq*low);
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++, low++;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
74 ms |
1352 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
58 ms |
1448 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |