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>
using namespace std;
#include "gap.h"
using ll = long long;
ll findGap(int T, int N){
if (T == 1){
ll mn, mx;
vector<ll> L, R;
ll lb = -1, rb = 1e18 + 1;
while (N > 0 && lb + 1 > rb - 1){
MinMax(lb + 1, rb - 1, &mn, &mx);
if (mn < 0) break;
L.push_back(mn); R.push_back(mx);
N--; if (mn != mx) N--;
lb = mn; rb = mx;
}
ll res = 0;
for (int i = 1; i < (int)L.size(); i++){
res = max(res, abs(L[i] - L[i-1]));
}
for (int i = 1; i < (int)R.size(); i++){
res = max(res, abs(R[i] - R[i-1]));
}
res = max(res, abs(R.back() - L.back()));
return res;
}
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |