This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "prize.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
int a[200001], ans = -1;
void solve(int l, int r) {
if ( ans != -1 || l > r )
return;
vector <int> resl = ask(l);
vector <int> resr = ask(r);
if ( resl[0] + resl[1] == 0 ) {
ans = l;
return;
}
if ( resr[0] + resr[1] == 0 ) {
ans = r;
return;
}
if (resl[0] + resl[1] < resr[0] + resr[1]) {
solve(l + 1, r);
return;
}
if (resl[0] + resl[1] > resr[0] + resr[1]) {
solve(l, r - 1);
return;
}
if ( resl[0] == resr[0] && resl[1] == resr[1] )
return;
int mid = (l + r) / 2;
solve(l, mid);
solve(mid, r);
}
int find_best(int n) {
solve(0, n - 1);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |