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;
using ll = long long;
#define x first
#define y second
pair<ll, ll> ask(ll s, ll e){
pair<ll, ll> p;
MinMax(s, e, &p.x, &p.y);
return p;
}
long long findGap(int T, int N){
vector<ll> A;
if(T == 1){
ll L = 0, R = 2e18;
while(N >= 1){
pair<ll, ll> r = ask(L, R);
A.push_back(r.x);
A.push_back(r.y);
L = r.x + 1, R = r.y - 1;
N -= 2;
}
} else {
pair<ll, ll> r = ask(0, 1e18 + 5);
ll md = (r.y - r.x) / (N - 1) + 1;
for(ll i = r.x; i <= r.y; i += md + 1){
pair<ll, ll> p = ask(i, i + md);
A.push_back(p.x);
A.push_back(p.y);
}
}
sort(A.begin(), A.end());
ll ans = 0;
for(int i = 0; i < A.size() - 1; i++){
ans = max(ans, A[i + 1] - A[i]);
}
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for(int i = 0; i < A.size() - 1; i++){
| ~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |