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;
using ll=long long;
#include "gap.h"
ll findGap(int T, int N) {
ll s, e, res=0;
MinMax(0, (ll)1e18, &s, &e);
s++, e--;
vector<ll> a, b;
for(ll i=1; i<=N+1; i++) {
ll l=s+((e-s+1)*(i-1)/N), r=min(e, s+((e-s+1)*i/N-1));
if(l>r) continue;
ll x, y;
MinMax(l, r, &x, &y);
if(x!=-1) {
a.push_back(x);
b.push_back(y);
}
}
res=max(a[0]-s+1, e-b.back()+1);
for(int i=0; i<a.size()-1; i++) res=max(res, a[i+1]-b[i]);
return res;
}
Compilation message (stderr)
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for(int i=0; i<a.size()-1; i++) res=max(res, a[i+1]-b[i]);
| ~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |