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;
typedef long long ll;
typedef pair<int,int> pii;
const ll INF = 1e18;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
ll findGap(int T, int N) {
if(T == 1) {
vector<ll> a(N);
int l = 0, r = N-1;
ll val1 = 0, val2 = INF;
while(l <= r) {
MinMax(val1, val2, &a[l], &a[r]);
val1 = a[l] + 1;
val2 = a[r] - 1;
l++;
r--;
}
ll ans = 0;
for(int i = 1; i < N; i++)
ans = max(ans, a[i] - a[i-1]);
return ans;
}
ll at, last;
MinMax(0, INF, &at, &last);
ll ans = (last-at + N-2)/(N-1), val = at + ans + 1;
while(at < last) {
ll a, b;
MinMax(at+1, val, &a, &b);
if(a != -1) {
ans = max(ans, a - at);
at = b;
val = at + ans + 1;
continue;
}
ans++;
val += ans;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |