#include "gap.h"
#include <bits/stdc++.h>
using ll = long long;
long long findGap(int T, int N)
{
if (T == 1) {
ll low = 0;
ll high = (ll)(1e18);
ll arr[N];
int l = 0;
int r = N-1;
while (l <= r) {
MinMax(low, high, &low, &high);
arr[l++] = low;
arr[r--] = high;
low++;
high--;
}
ll mx = 0;
for (int i = 1; i < N; i++) {
mx = std::max(mx, arr[i] - arr[i-1]);
}
return mx;
}
else {
ll first = 0;
ll last = 0;
MinMax(first, (ll)(1e18), &first, &last);
ll d = (last-first + N-2)/(N-1);
ll ans = 0;
ll next = first+d;
first++;
while (first < last) {
ll mn, mx;
MinMax(first, next, &mn, &mx);
if (mn != -1) {
ans = std::max(mn - (first-1), ans);
first = mx+1;
}
next += d;
}
return ans;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
2 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
2 ms |
364 KB |
Output is correct |
16 |
Correct |
12 ms |
748 KB |
Output is correct |
17 |
Correct |
12 ms |
748 KB |
Output is correct |
18 |
Correct |
11 ms |
748 KB |
Output is correct |
19 |
Correct |
12 ms |
748 KB |
Output is correct |
20 |
Correct |
10 ms |
748 KB |
Output is correct |
21 |
Correct |
44 ms |
1900 KB |
Output is correct |
22 |
Correct |
55 ms |
1900 KB |
Output is correct |
23 |
Correct |
45 ms |
1900 KB |
Output is correct |
24 |
Correct |
44 ms |
1900 KB |
Output is correct |
25 |
Correct |
39 ms |
1900 KB |
Output is correct |
26 |
Correct |
50 ms |
1900 KB |
Output is correct |
27 |
Correct |
44 ms |
2028 KB |
Output is correct |
28 |
Correct |
47 ms |
1900 KB |
Output is correct |
29 |
Correct |
46 ms |
1900 KB |
Output is correct |
30 |
Correct |
35 ms |
1900 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
3 ms |
364 KB |
Output is correct |
13 |
Correct |
2 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
2 ms |
364 KB |
Output is correct |
16 |
Correct |
15 ms |
696 KB |
Output is correct |
17 |
Correct |
15 ms |
492 KB |
Output is correct |
18 |
Correct |
15 ms |
640 KB |
Output is correct |
19 |
Correct |
15 ms |
492 KB |
Output is correct |
20 |
Correct |
11 ms |
492 KB |
Output is correct |
21 |
Correct |
60 ms |
1132 KB |
Output is correct |
22 |
Correct |
63 ms |
1132 KB |
Output is correct |
23 |
Correct |
62 ms |
1260 KB |
Output is correct |
24 |
Correct |
61 ms |
1116 KB |
Output is correct |
25 |
Correct |
55 ms |
1116 KB |
Output is correct |
26 |
Correct |
62 ms |
1260 KB |
Output is correct |
27 |
Correct |
61 ms |
1132 KB |
Output is correct |
28 |
Correct |
61 ms |
1132 KB |
Output is correct |
29 |
Correct |
62 ms |
1132 KB |
Output is correct |
30 |
Correct |
42 ms |
1132 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |