이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#include "prize.h"
#ifdef LOCAL
#include "debug.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif
pair<int,int> ret[200001];
int fin = -1;
pair<int,int> ans(int x){
if(ret[x].first!=-1)return ret[x];
vector<int>lol = ask(x);
ret[x] = {lol[0],lol[1]};
if(ret[x].first==ret[x].second&&ret[x].first==0){
fin = x;
}
return ret[x];
}
void solve(int l,int r){
if(fin!=-1)return ;
if(l>r)return ;
if(l==r){
ans(l);
return ;
}
while(ans(l).first+ans(l).second!=ans(r).first+ans(r).second){
while(ans(l).first+ans(l).second<ans(r).first+ans(r).second)l++;
while(ans(l).first+ans(l).second>ans(r).first+ans(r).second)r--;
}
int mid = (l+r)/2;
if(ans(l).second==ans(r).second){
return ;
}
solve(l,mid);
solve(mid+1,r);
}
int find_best(int n){
solve(0,n-1);
return fin;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |