This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//In the name of God
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
typedef int ll;
typedef pair<ll, ll> pll;
const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
ll p[maxn];
int find_best(int n){
srand(time(NULL));
for(ll i = 0; i < n; i++){
p[i] = i;
}
random_shuffle(p, p + n);
ll x = 0;
for(ll i = 0; i < min(10, n); i++){
auto f = ask(p[i]);
x = max(x, f[0] + f[1]);
}
ll ptr = 0;
while(ptr < n){
auto f = ask(ptr);
if(f[0] + f[1] == 0) return ptr;
if(f[0] + f[1] != x){
ptr++;
continue;
}
ll l = ptr, r = n;
while(r - l > 1){
ll mid = (l + r) >> 1;
auto f2 = ask(mid);
if(f2[0] == f[0] && f2[1] == f[1]) l = mid;
else r = mid;
}
ptr = r;
}
return -1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |