#include "bits/stdc++.h"
#include "prize.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
const int BL = 10000;
int suf = -1;
vector<int> Cache = {-1, -1};
map<int,vector<int>> dp;
vector<bool> mark;
vector<int> Ask(int i){
if( dp.count(i) ) return dp[i];
return dp[i] = ask(i);
}
void Learn(int l,int r){
if(l > r) return;
if(l == r){
mark[l] = 1;
suf--;
return;
}
int mid = (l + r) / 2;
auto u = Ask(mid);
if(u[1] == suf){
Learn(mid + 1, r);
return;
}
Learn(l, mid - 1);
if(u[1] < suf) suf--;
Learn(mid + 1, r);
return;
}
int find_best(int n){
mark.assign(n,0);
int art = 0;
bool no = 0;
for(int i = 0; i <= 475; i++){
if(art == 5){
Learn(i, n - 1);
no = 1;
break;
}
vector<int> x = Ask(i);
if(x[0] + x[1] == 0) return i;
if(x[0] + x[1] > Cache[0] + Cache[1]) art++;
if(x[0] + x[1] >= Cache[0] + Cache[1]){
Cache = x;
suf = Cache[1];
}
else suf--;
}
if(no == 0) Learn(476, n - 1);
for(auto x:dp) if(x.second[0] + x.second[1] == 0) return x.first;
for(int i=0;i<n;i++){
if(mark[i]==0) continue;
vector<int> Cand = Ask(i);
if(Cand[0] + Cand[1] == 0) return i;
}
assert(0);
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
216 ms |
1416 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
204 ms |
1632 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |