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 <bits/stdc++.h>
#include "gap.h"
#define DEBUG 0
using namespace std;
const long long INF = 1e18;
long long findGap(int T, int N) {
vector <long long> a;
if(T == 1) {
a.resize(N);
MinMax(0, INF, &a[0], &a[N - 1]);
int l = 1, r = N - 2;
while(l <= r) {
MinMax(a[l - 1] + 1, a[r + 1] - 1, &a[l], &a[r]);
l++;
r--;
}
}
else {
long long L, R;
MinMax(0, INF, &L, &R);
long long minimum = (R - L + N - 2) / (N - 1);
L++;
while(L < R) {
long long nL, nR;
MinMax(L, min(L + minimum, R - 1), &nL, &nR);
if(nL != -1 and nR != -1) {
a.push_back(nL);
a.push_back(nR);
}
L = min(L + minimum, R - 1) + 1;
}
}
long long ans = 0;
for(int i = 1; i < a.size(); i++) {
ans = max(ans, a[i] - a[i - 1]);
}
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i = 1; i < a.size(); i++) {
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |