이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long ll;
long long findGap(int t, int n)
{
ll lo = 0, hi = (ll)1e18;
if (t == 1) {
ll le = 0, ri = n-1, x, y;
vector<ll> a(n);
while (le <= ri) {
MinMax(lo,hi,&x,&y);
if (x == -1) break;
a[le] = x;
a[ri] = y;
lo = x+1;
hi = y-1;
le++;
ri--;
}
ll ans = 0;
for (int q = 1; q < n; q++) {
ans = max(ans, a[q]-a[q-1]);
}
return ans;
} else {
ll x,y;
MinMax(lo,hi,&x,&y);
if (n == 2) return y-x;
ll piece = (y-x-1)/(n-1);
ll add = y-x-1-(n-1)*piece;
vector<pair<ll,ll>> inter;
ll last = x;
for (int q = 0; q < n-1; q++) {
inter.emplace_back(last+1,last+1+piece);
if (add > 0) inter.back().second++;
last = inter.back().second;
}
ll a,b;
vector<pair<ll,ll>> res;
for (int q = 0; q < n-1; q++) {
MinMax(inter[q].first,inter[q].second,&a,&b);
res.emplace_back(a,b);
}
ll ans = 0;
last = x;
for (int q = 0; q < n-1; q++) {
if (res[q].first == -1) continue;
ans = max(ans, res[q].first-last);
last = res[q].second;
}
ans = max(ans, y-last);
return ans;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |