이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
const int LOG = 18, TAKE = 500;
int find_best(int n) {
// find max
int mx = 0;
for(int i = 0; i < min(TAKE, n); i++){
auto c = ask(i);
int s = c[0] + c[1];
if(s == 0) return i;
mx = max(mx, s);
}
function<int(int, int)> find = [&](int l , int r){
int cntl = 0, cntr = 0;
for(; 1; l++){
auto c = ask(l);
int s = c[0] + c[1];
if(s == 0) return l;
cntl = c[0];
if(s == mx){
break;
}
}
for(; 1; r--){
auto c = ask(r);
int s = c[0] + c[1];
if(s == 0) return r;
cntr = c[0];
if(s == mx){
break;
}
}
if(cntl != cntr){
int m = (l + r) / 2;
int ret;
if((ret = find(l, m)) != -1){
return ret;
}
if((ret = find(m + 1, r)) != -1){
return ret;
}
}
return -1;
};
return find(0, n - 1);
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |