# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
742029 | vjudge1 | Gap (APIO16_gap) | C++17 | 70 ms | 4836 KiB |
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;
long long findGap(int T, int N){
long long l = 0, r = 1e18;
vector<long long>a;
long long mn, mx;
long long L[N+1], R[N+1];
MinMax(l, r, &mn, &mx);
long long len = mx-mn+1;
R[0] = mn-1;
for(int i=1; i<N; i++){
L[i] = R[i-1] + 1;
R[i] = L[i] + len/(N-1);
if(i > len%(N-1)) R[i]--;
MinMax(L[i], R[i], &mn, &mx);
a.push_back(mn);
a.push_back(mx);
}
long long ans = (len+N-2) / (N-1);
sort(a.begin(), a.end());
for(int i=1; i<a.size(); i++) ans = max(ans, a[i]-a[i-1]);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |