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<bits/stdc++.h>
using namespace std;
const int maxn = 1e18;
long long findGap(int T, int N){
long long l = 0, r = 0, mn = 0, mx = 0;
MinMax(1, maxn, &mn, &mx);
l = mn; r = mx;
long long sz = (r - l + 1) / (N - 1), j = 0;
vector<pair<long long,long>>d;
for(j = l; j <= r; j += sz+1){
MinMax(j, j + sz, &mn, &mx);
d.push_back({mn, mx});
}
MinMax(j, r, &mn, &mx);
d.push_back({mn, mx});
long long ans = sz;
mx = d[0].second;
for(int i = 1; i < (int)d.size(); i++){
if(d[i].first != -1){
ans = max(ans, d[i].first - mx);
mx = d[i].second;
}
}
return ans;
}
Compilation message (stderr)
gap.cpp:4:18: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
4 | const int maxn = 1e18;
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |