# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
956185 |
2024-04-01T09:16:13 Z |
thinknoexit |
Gap (APIO16_gap) |
C++17 |
|
39 ms |
1988 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;
ll a[100100];
int n;
ll ans = 1;
ll findGap(int T, int N) {
n = N;
if (T == 1) {
a[0] = -1, a[n + 1] = inf + 1;
for (int i = 1;i <= n / 2;i++) {
MinMax(a[i - 1] + 1, a[n - i + 2] - 1, &a[i], &a[n - i + 1]);
}
if (n & 1) {
ll _;
MinMax(a[n / 2] + 1, a[n / 2 + 2] - 1, &a[n / 2 + 1], &_);
}
for (int i = 1;i < n;i++) {
ans = max(ans, a[i + 1] - a[i]);
}
return ans;
}
ll mn, mx;
MinMax(0, inf, &mn, &mx);
ll now = mn;
while (now < mx) {
ll n1, n2;
MinMax(now + 1, now + ans, &n1, &n2);
if (n2 != -1) {
now = n2;
continue;
}
ll l = ans + 1, r = mx - now;
ll pnow = now + ans;
while (1) {
ll mid = (l + r) / 2;
ll nl, nr;
MinMax(pnow + 1, now + mid, &nl, &nr);
if (nl == -1) l = mid + 1, pnow = now + mid;
else {
ans = nl - now;
if (nr - nl <= ans) now = nr;
else now = nl;
break;
}
}
//cout << ans << ' ';
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
9 ms |
812 KB |
Output is correct |
17 |
Correct |
9 ms |
636 KB |
Output is correct |
18 |
Correct |
8 ms |
644 KB |
Output is correct |
19 |
Correct |
8 ms |
644 KB |
Output is correct |
20 |
Correct |
7 ms |
620 KB |
Output is correct |
21 |
Correct |
34 ms |
1980 KB |
Output is correct |
22 |
Correct |
31 ms |
1980 KB |
Output is correct |
23 |
Correct |
30 ms |
1988 KB |
Output is correct |
24 |
Correct |
30 ms |
1980 KB |
Output is correct |
25 |
Correct |
27 ms |
1988 KB |
Output is correct |
26 |
Correct |
30 ms |
1972 KB |
Output is correct |
27 |
Correct |
30 ms |
1904 KB |
Output is correct |
28 |
Correct |
30 ms |
1980 KB |
Output is correct |
29 |
Correct |
30 ms |
1976 KB |
Output is correct |
30 |
Correct |
29 ms |
1948 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
344 KB |
Partially correct |
2 |
Partially correct |
0 ms |
344 KB |
Partially correct |
3 |
Partially correct |
1 ms |
344 KB |
Partially correct |
4 |
Partially correct |
1 ms |
344 KB |
Partially correct |
5 |
Partially correct |
1 ms |
344 KB |
Partially correct |
6 |
Partially correct |
0 ms |
344 KB |
Partially correct |
7 |
Partially correct |
0 ms |
344 KB |
Partially correct |
8 |
Partially correct |
1 ms |
344 KB |
Partially correct |
9 |
Partially correct |
0 ms |
344 KB |
Partially correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Partially correct |
1 ms |
344 KB |
Partially correct |
12 |
Partially correct |
1 ms |
344 KB |
Partially correct |
13 |
Partially correct |
1 ms |
344 KB |
Partially correct |
14 |
Partially correct |
1 ms |
344 KB |
Partially correct |
15 |
Partially correct |
1 ms |
344 KB |
Partially correct |
16 |
Partially correct |
6 ms |
644 KB |
Partially correct |
17 |
Partially correct |
6 ms |
648 KB |
Partially correct |
18 |
Partially correct |
5 ms |
652 KB |
Partially correct |
19 |
Partially correct |
5 ms |
812 KB |
Partially correct |
20 |
Correct |
5 ms |
872 KB |
Output is correct |
21 |
Partially correct |
20 ms |
1204 KB |
Partially correct |
22 |
Partially correct |
19 ms |
1232 KB |
Partially correct |
23 |
Partially correct |
25 ms |
1052 KB |
Partially correct |
24 |
Partially correct |
19 ms |
1444 KB |
Partially correct |
25 |
Partially correct |
39 ms |
1196 KB |
Partially correct |
26 |
Partially correct |
23 ms |
1028 KB |
Partially correct |
27 |
Partially correct |
19 ms |
1212 KB |
Partially correct |
28 |
Partially correct |
20 ms |
1220 KB |
Partially correct |
29 |
Partially correct |
21 ms |
1248 KB |
Partially correct |
30 |
Correct |
19 ms |
1136 KB |
Output is correct |
31 |
Partially correct |
1 ms |
344 KB |
Partially correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |