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()
vector<pair<ll, pll> > vec;
int find_best(int n){
ll p = n / 500;
ll x = 0;
for(ll i = 0; i < n; i += p){
auto f = ask(i);
vec.pb(Mp(i, Mp(f[0], f[1])));
x = max(x, f[0] + f[1]);
}
ll ptr = 0;
while(ptr < n){
auto f = ask(ptr);
vec.pb(Mp(ptr, Mp(f[0], f[1])));
if(f[0] + f[1] == 0) return ptr;
if(f[0] + f[1] != x){
ptr++;
continue;
}
ll l = ptr, r = n;
for(auto i : vec){
if(i.F < ptr) continue;
if(i.S.F == f[0] && i.S.S == f[1]) l = max(l, i.F);
else r = min(r, i.F);
}
while(r - l > 1){
ll mid = (l + r) >> 1;
auto f2 = ask(mid);
vec.pb(Mp(mid, Mp(f2[0], f2[1])));
if(f2[0] == f[0] && f2[1] == f[1]) l = mid;
else r = mid;
}
ptr = r;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |