# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
733923 | 2023-05-01T12:03:13 Z | turbat | Gap (APIO16_gap) | C++14 | 52 ms | 1876 KB |
#include "gap.h" #include <algorithm> #include <iostream> using namespace std; long long Subtask1(int T, int N) { long long mn = 0, mx = 0, r = N, l = 1, a[N + 1], right = 1e18, left = 0, k = 0; while (r >= l) { MinMax(left, right, &left, &right); a[l] = left; a[r] = right; left++; right--; l++; r--; } long long ans = 0; for (int i = 1; i < N; i++) ans = max(ans, a[i + 1] - a[i]); return ans; } long long findGap(int T, int N) { if (T == 1) { return Subtask1(T, N); } long long mn, mx; MinMax(-1, 1e18 + 1, &mn, &mx); long long gap = (mx - mn) / (N - 1); // cout << gap << endl; for (long long cur = mn; cur < mx;) { long long l, r; // cout << cur << " " << cur + gap << " "; MinMax(cur, cur + gap, &l, &r); // cout << l << " " << r << endl; if (l == r) { long long tmp = gap; l = -1; while (l == -1 && cur + tmp - gap + 1 <= mx) { tmp += gap; // cout << "WHILE: " << cur + tmp - gap + 1 << " " << cur + tmp // << " "; MinMax(cur + tmp - gap + 1, cur + tmp, &l, &r); // cout << l << " " << r << endl; } // cout << l << " " << cur << endl; gap = l - cur; // cout << gap << endl; } cur = r; } // cout << "GAP: " << gap << endl; return gap; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 208 KB | Output is correct |
4 | Correct | 0 ms | 208 KB | Output is correct |
5 | Correct | 0 ms | 208 KB | Output is correct |
6 | Correct | 0 ms | 208 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
8 | Correct | 0 ms | 208 KB | Output is correct |
9 | Correct | 0 ms | 208 KB | Output is correct |
10 | Correct | 0 ms | 208 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 9 ms | 592 KB | Output is correct |
17 | Correct | 9 ms | 592 KB | Output is correct |
18 | Correct | 10 ms | 680 KB | Output is correct |
19 | Correct | 12 ms | 592 KB | Output is correct |
20 | Correct | 7 ms | 704 KB | Output is correct |
21 | Correct | 38 ms | 1860 KB | Output is correct |
22 | Correct | 38 ms | 1736 KB | Output is correct |
23 | Correct | 44 ms | 1876 KB | Output is correct |
24 | Correct | 39 ms | 1856 KB | Output is correct |
25 | Correct | 31 ms | 1872 KB | Output is correct |
26 | Correct | 36 ms | 1828 KB | Output is correct |
27 | Correct | 37 ms | 1764 KB | Output is correct |
28 | Correct | 35 ms | 1864 KB | Output is correct |
29 | Correct | 35 ms | 1860 KB | Output is correct |
30 | Correct | 30 ms | 1872 KB | Output is correct |
31 | Correct | 1 ms | 208 KB | Output is correct |
32 | Correct | 1 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Partially correct | 0 ms | 208 KB | Partially correct |
3 | Partially correct | 0 ms | 208 KB | Partially correct |
4 | Partially correct | 0 ms | 208 KB | Partially correct |
5 | Partially correct | 1 ms | 208 KB | Partially correct |
6 | Correct | 0 ms | 208 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
8 | Correct | 1 ms | 208 KB | Output is correct |
9 | Correct | 0 ms | 208 KB | Output is correct |
10 | Correct | 1 ms | 208 KB | Output is correct |
11 | Correct | 1 ms | 208 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Partially correct | 1 ms | 336 KB | Partially correct |
16 | Correct | 8 ms | 512 KB | Output is correct |
17 | Correct | 6 ms | 488 KB | Output is correct |
18 | Correct | 6 ms | 464 KB | Output is correct |
19 | Correct | 6 ms | 428 KB | Output is correct |
20 | Correct | 5 ms | 512 KB | Output is correct |
21 | Correct | 23 ms | 1056 KB | Output is correct |
22 | Correct | 28 ms | 1060 KB | Output is correct |
23 | Correct | 31 ms | 1164 KB | Output is correct |
24 | Correct | 24 ms | 988 KB | Output is correct |
25 | Partially correct | 52 ms | 1064 KB | Partially correct |
26 | Correct | 25 ms | 1012 KB | Output is correct |
27 | Correct | 24 ms | 1056 KB | Output is correct |
28 | Correct | 29 ms | 1004 KB | Output is correct |
29 | Correct | 23 ms | 1060 KB | Output is correct |
30 | Correct | 20 ms | 968 KB | Output is correct |
31 | Correct | 0 ms | 208 KB | Output is correct |
32 | Correct | 0 ms | 208 KB | Output is correct |