This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "prize.h"
#define vc vector
using namespace std;
int find_best(int n){
map<int, map<int, int>> pod;
function<int (int, int)> solve=[&](int l, int r){
if(l>r) return -1;
int mid=(l+r)/2;
for(auto v: pod){
int kokvseh=v.first;
int kokprej=-1, kokpol=-1;
auto pol = v.second.upper_bound( mid);
if(pol!=v.second.end()) kokpol=(pol->second);
if(pol!=v.second.begin()) {auto prej = pol;--prej; kokprej=(prej->second);}
if(kokpol==0) return -1;
if(kokprej==kokvseh) return -1;
if(kokpol==kokprej) return -1;
}
vc<int> q=ask(mid);
if(q[0]+q[1]==0) return mid;
pod[q[0]+q[1]][mid]=q[0];
return max(solve(l, mid-1), solve(mid+1, r));
};
return solve(0, n-1);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |