이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()
template<typename T>
int len(T &a){
return a.size();
}
int _q = 0;
int find_best(int n) {
// if(n <= 5000){
// for(int i = 0; i < n; i ++){
// if(ask(i) == vector<int>{0, 0}){
// return i;
// }
// }
// }
int j = 0;
int rig = 0;
_q = 0;
while(true){
auto v = ask(j);
_q ++;
if(v[0] + v[1] == 0){
return j;
}
if(n - v[0] + v[1] > n / 2){
rig = v[1];
break;
}
j ++;
rig --;
}
// cout << 3 << ' ';
// for(int i = 0; i < 400; i++){
// cout << "2 ";
// }
// for(int i = 0; i < 199000; i ++){
// cout << "3 ";
// }
// cout << "1 ";
//cout << j << endl;
while(true){
int l = j, r = n;
while(r - l > 1){
int m = (l + r) / 2;
_q ++;
assert(_q <= 10000);
vector<int> v = ask(m);
if(v[0] + v[1] == 0){
return m;
}
if(v[1] == rig){
l = m;
}else r = m;
}
//cout << r << ' ' << rig << endl;
j = r + 1;
rig --;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |