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 "gap.h"
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define pb push_back
#define pii pair<long long, long long>
#define len(x) (long long)x.size()
template<typename A, typename B>
bool cmax(A &a, const B &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template<typename A, typename B>
bool cmin(A &a, const B &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
int askcount = 0;
pii ask(long long x) {
askcount++;
long long mn = 0, mx = 0;
MinMax(x, x, &mn, &mx);
return {mn, mx};
}
long long findGap(int T, int N) {
long long best_dist = 0;
long long cur_value = 0;
while (true) {
if (askcount >= (N + 1) / 2) break;
pii res = ask(cur_value + best_dist + 1);
if (res.S == cur_value) cmax(best_dist, res.F - res.S);
cur_value = res.F;
if (res.F == -1) return best_dist;
}
return best_dist;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |