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 <vector>
#include <algorithm>
using namespace std;
long long findGap(int T, int N) {
long long s, e, mn, mx, res = 0;
if(T == 1) {
s=0, e=1e18;
vector<long long> v;
while(s <= e) {
MinMax(s, e, &mn, &mx);
if(mn == -1) break;
v.push_back(mn);
v.push_back(mx);
s = mn + 1, e = mx - 1;
}
sort(v.begin(), v.end());
for(int i=0; i+1<v.size(); i++)
res = max(res, v[i+1] - v[i]);
} else {
s=0, e=1e18;
MinMax(s, e, &mn, &mx);
long long len = (mx - mn + N - 2) / (N - 1);
vector<long long> v;
s=mn, e=mx;
while(s <= e) {
MinMax(s, s + len, &mn, &mx);
if(mn != -1) {
v.push_back(mn);
if(mn != mx) v.push_back(mx);
}
s += len + 1;
}
sort(v.begin(), v.end());
res = len;
for(int i=0; i+1<v.size(); i++)
res = max(res, v[i+1] - v[i]);
}
return res;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:19:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i+1<v.size(); i++)
~~~^~~~~~~~~
gap.cpp:37:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i+1<v.size(); i++)
~~~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |