#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;
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;
}
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 + (n-now)/(mx-low+1));
r = min(n-1, now + 2*mx);
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 |
105 ms |
1272 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
76 ms |
1560 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |