# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1076493 |
2024-08-26T14:15:49 Z |
Pannda |
Gap (APIO16_gap) |
C++17 |
|
35 ms |
3420 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
long long findGap(int type, int n) {
constexpr long long C = 1e18;
if (type == 1) {
vector<long long> a(n);
int idx_l = 0, idx_r = n - 1;
long long l = 0, r = C;
for (int t = 0; t < (n + 1) / 2; t++) {
MinMax(l, r, &a[idx_l], &a[idx_r]);
l = a[idx_l] + 1;
r = a[idx_r] - 1;
idx_l++;
idx_r--;
}
long long ans = 0;
for (int i = 0; i + 1 < n; i++) {
ans = max(ans, a[i + 1] - a[i]);
}
return ans;
} else {
long long x;
long long last;
MinMax(0, C, &x, &last);
long long ans = 1;
while (last - x > ans) {
// with x, find some d such that [x, x + d] is only x, and [x + d + 1, x + d + 1 + d] is none empty and is (mn, mx)
// update ans with mn - x, and set new x to mx
// jump x until [x + ans] is only x
while (last - x > ans) {
// assert( [x, x + ans] is only x)
long long s = x + ans + 1;
assert(s <= C);
long long mn, mx;
MinMax(s, s + ans, &mn, &mx);
if (mn == -1) {
ans = ans + ans + 1;
} else {
ans = mn - x;
x = mx;
break;
}
}
while (last - x > ans) {
long long mn, mx;
MinMax(x + 1, x + ans, &mn, &mx);
if (mn == -1) {
break;
} else {
x = mx;
}
}
}
return ans;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
344 KB |
Output is correct |
10 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
7 ms |
856 KB |
Output is correct |
17 |
Correct |
7 ms |
660 KB |
Output is correct |
18 |
Correct |
7 ms |
856 KB |
Output is correct |
19 |
Correct |
7 ms |
696 KB |
Output is correct |
20 |
Correct |
5 ms |
856 KB |
Output is correct |
21 |
Correct |
26 ms |
1960 KB |
Output is correct |
22 |
Correct |
26 ms |
1880 KB |
Output is correct |
23 |
Correct |
26 ms |
1880 KB |
Output is correct |
24 |
Correct |
27 ms |
3420 KB |
Output is correct |
25 |
Correct |
30 ms |
1880 KB |
Output is correct |
26 |
Correct |
25 ms |
1880 KB |
Output is correct |
27 |
Correct |
27 ms |
1880 KB |
Output is correct |
28 |
Correct |
27 ms |
1880 KB |
Output is correct |
29 |
Correct |
26 ms |
1880 KB |
Output is correct |
30 |
Correct |
22 ms |
1880 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
Partially correct |
2 |
Partially correct |
0 ms |
344 KB |
Partially correct |
3 |
Partially correct |
0 ms |
344 KB |
Partially correct |
4 |
Partially correct |
1 ms |
344 KB |
Partially correct |
5 |
Partially correct |
0 ms |
344 KB |
Partially correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Partially correct |
1 ms |
344 KB |
Partially correct |
16 |
Correct |
5 ms |
436 KB |
Output is correct |
17 |
Correct |
4 ms |
600 KB |
Output is correct |
18 |
Correct |
5 ms |
600 KB |
Output is correct |
19 |
Correct |
4 ms |
600 KB |
Output is correct |
20 |
Correct |
3 ms |
600 KB |
Output is correct |
21 |
Correct |
16 ms |
2756 KB |
Output is correct |
22 |
Correct |
19 ms |
1108 KB |
Output is correct |
23 |
Correct |
17 ms |
1112 KB |
Output is correct |
24 |
Correct |
18 ms |
1112 KB |
Output is correct |
25 |
Partially correct |
35 ms |
1112 KB |
Partially correct |
26 |
Correct |
22 ms |
1112 KB |
Output is correct |
27 |
Correct |
17 ms |
2648 KB |
Output is correct |
28 |
Correct |
28 ms |
2648 KB |
Output is correct |
29 |
Correct |
17 ms |
1112 KB |
Output is correct |
30 |
Correct |
13 ms |
1112 KB |
Output is correct |
31 |
Partially correct |
1 ms |
340 KB |
Partially correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |