이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prize.h"
#include <iostream>
using namespace std;
vector <int> a;
int maxs;
int find_prize(int l, int r, int bigl, int bigr) {
int mid=(l+r)/2;
while (mid<=r) {
a=ask(mid);
if (a[0]+a[1]==0) return mid;
if (a[0]+a[1]==maxs) break;
mid++;
}
int ans=-1;
if (mid<=r && a[0]+1<=bigr) {
ans=find_prize(mid+1,r,a[0]+1,bigr);
if (ans!=-1) return ans;
}
mid=(l+r)/2-1;
while (mid>=l) {
a=ask(mid);
if (a[0]+a[1]==0) return mid;
if (a[0]+a[1]==maxs) break;
}
if (mid>=l && a[0]>=bigl) {
ans=find_prize(l,mid-1,bigl,a[0]);
if (ans!=-1) return ans;
}
return ans;
}
int find_best(int n) {
for (int i=0;i<700;i++) {
a=ask(rand()%n);
maxs=max(maxs,a[0]+a[1]);
}
int ans=find_prize(0,n-1,1,maxs);
return ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |