이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <algorithm>
using namespace std;
const int MAX_N = 100000;
typedef long long ll;
ll a[MAX_N*2];
long long findGap(int T, int N)
{
ll ans = 1, s = 0, t = 1e18, mn, mx;
int n = 0;
if (T == 1) {
ll head = 0, tail = N-1;
while (head <= tail) {
MinMax(s, t, &mn, &mx);
a[head++] = mn;
a[tail--] = mx;
s = mn+1;
t = mx-1;
}
n = N;
} else {
MinMax(s, t, &mn, &mx);
ll d = (mx-mn+N-1)/N, x, y;
a[n++] = mn;
for (s = mn+1, t = s+d; s < mx; s = t+1, t = s+d) {
MinMax(s, min(t, mx-1), &x, &y);
if (x == -1)
continue;
a[n++] = x;
a[n++] = y;
}
a[n++] = mx;
}
for (int i = 1; i < n; ++i)
ans = max(ans, a[i] - a[i-1]);
return ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |