# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
720039 |
2023-04-07T10:01:58 Z |
Forested |
Gap (APIO16_gap) |
C++17 |
|
63 ms |
1076 KB |
#include "gap.h"
#include <algorithm>
long long findGap(int t, int n) {
if (t == 1) {
long long ans = 0;
long long pmn = -1, pmx = 1000000000000000001, mn = -1, mx = -1;
for (int i = 0; i < (n + 1) / 2; ++i) {
MinMax(pmn + 1, pmx - 1, &mn, &mx);
if (i != 0) {
ans = std::max({ans, mn - pmn, pmx - mx});
}
pmn = mn;
pmx = mx;
}
ans = std::max(ans, pmx - pmn);
return ans;
}
long long mn = -1, mx = -1;
MinMax(0, 1000000000000000000, &mn, &mx);
long long l = mn, h = mx;
long long w = (h - l + n - 1) / n;
long long cur = l + 1, pmx = l, ans = 0;
while (cur <= h) {
MinMax(cur, cur + w - 1, &mn, &mx);
if (mn != -1) {
if (pmx != -1) {
ans = std::max(ans, mn - pmx);
}
pmx = mx;
}
cur += w;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 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 |
0 ms |
324 KB |
Output is correct |
8 |
Correct |
1 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 |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
220 KB |
Output is correct |
15 |
Correct |
1 ms |
252 KB |
Output is correct |
16 |
Correct |
10 ms |
492 KB |
Output is correct |
17 |
Correct |
13 ms |
408 KB |
Output is correct |
18 |
Correct |
10 ms |
488 KB |
Output is correct |
19 |
Correct |
10 ms |
464 KB |
Output is correct |
20 |
Correct |
8 ms |
496 KB |
Output is correct |
21 |
Correct |
37 ms |
1048 KB |
Output is correct |
22 |
Correct |
43 ms |
1048 KB |
Output is correct |
23 |
Correct |
40 ms |
1060 KB |
Output is correct |
24 |
Correct |
41 ms |
988 KB |
Output is correct |
25 |
Correct |
34 ms |
936 KB |
Output is correct |
26 |
Correct |
37 ms |
1060 KB |
Output is correct |
27 |
Correct |
46 ms |
1020 KB |
Output is correct |
28 |
Correct |
42 ms |
928 KB |
Output is correct |
29 |
Correct |
37 ms |
1028 KB |
Output is correct |
30 |
Correct |
30 ms |
1028 KB |
Output is correct |
31 |
Correct |
0 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 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 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 |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
12 ms |
492 KB |
Output is correct |
17 |
Correct |
12 ms |
464 KB |
Output is correct |
18 |
Correct |
14 ms |
428 KB |
Output is correct |
19 |
Correct |
14 ms |
584 KB |
Output is correct |
20 |
Correct |
7 ms |
464 KB |
Output is correct |
21 |
Correct |
51 ms |
1060 KB |
Output is correct |
22 |
Correct |
51 ms |
1056 KB |
Output is correct |
23 |
Correct |
51 ms |
1044 KB |
Output is correct |
24 |
Correct |
50 ms |
948 KB |
Output is correct |
25 |
Correct |
54 ms |
1060 KB |
Output is correct |
26 |
Correct |
55 ms |
976 KB |
Output is correct |
27 |
Correct |
51 ms |
1056 KB |
Output is correct |
28 |
Correct |
57 ms |
1044 KB |
Output is correct |
29 |
Correct |
63 ms |
1024 KB |
Output is correct |
30 |
Correct |
30 ms |
1076 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |