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 <climits>
#include <vector>
using namespace std;
long long findGap(int T, int N) {
long long L, R;
MinMax(0, LLONG_MAX, &L, &R);
long long diff = ((R - L - 1) + (N - 2))/(N - 1);
vector<pair<long long, long long> > cands;
cands.push_back({L, L});
for(long long x = L + 1; x <= R - 1; x += diff) {
long long qL, qR;
MinMax(x, min(x + diff - 1, R - 1), &qL, &qR);
if(qL != -1) cands.push_back({qL, qR});
}
cands.push_back({R, R});
long long ans = 0;
for(int i = 1; i < cands.size(); i++) {
ans = max(ans, cands[i].first - cands[i - 1].second);
}
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:23:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1; i < cands.size(); i++) {
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |