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 "prize.h"
#include<bits/stdc++.h>
using namespace std;
vector< pair<int,int> > v;
int sum;
int ans;
void recur(int l, int r, int lhs, int rhs) {
if(ans!=-1) return;
if(l>r) return;
int mid = (l+r)/2;
for(int i=mid; i<=r; i++) {
vector<int> tmp = ask(i);
if(tmp[0]+tmp[1]==0) {
ans=i;
return;
}
if(tmp[0]-lhs>0) recur(l, mid-1, lhs, tmp[1]);
if(tmp[1]-rhs>0) recur(i+1, r, tmp[0], rhs);
v.push_back({tmp[0]+tmp[1], i});
return;
}
}
int find_best(int n) {
if(n<=5000) {
for(int i=0; i<n; i++) {
vector<int> tmp = ask(i);
if(tmp[0]+tmp[1]==0) return i;
}
}
sum = 0;
for(int tmp=sqrt(sqrt(n)); tmp>=2; tmp=sqrt(tmp)) {
sum += tmp;
}
sum++;
ans = -1;
recur(0, n-1, 0, 0);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |