# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
109558 |
2019-05-07T05:11:23 Z |
PeppaPig |
Gap (APIO16_gap) |
C++14 |
|
85 ms |
1464 KB |
#include "gap.h"
#include <bits/stdc++.h>
#define long long long
using namespace std;
const int N = 1e5+5;
long findGap(int T, int n) {
long l, r;
MinMax(0, 2e18, &l, &r);
if(T == 1) {
long ans = 0;
for(int i = 1; i < (n + 1) / 2; i++) {
long nl, nr;
MinMax(l + 1, r - 1, &nl, &nr);
if(nl != -1) ans = max(ans, nl - l), l = nl;
if(nr != -1) ans = max(ans, r - nr), r = nr;
}
if(l != r) ans = max(ans, r - l);
return ans;
} else {
long gap = (r - l + n - 1) / n, ans = 0, pv = l;
for(long i = l + 1, j = i + gap; ; i = j + 1, j = i + gap) {
long nl, nr;
j = min(j, r - 1);
if(i > j) break;
MinMax(i, j, &nl, &nr);
if(nl != -1) ans = max(ans, nl - pv);
if(nr != -1) pv = nr;
}
return max(ans, r - pv);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
512 KB |
Output is correct |
15 |
Correct |
3 ms |
512 KB |
Output is correct |
16 |
Correct |
16 ms |
640 KB |
Output is correct |
17 |
Correct |
18 ms |
640 KB |
Output is correct |
18 |
Correct |
20 ms |
760 KB |
Output is correct |
19 |
Correct |
16 ms |
640 KB |
Output is correct |
20 |
Correct |
12 ms |
640 KB |
Output is correct |
21 |
Correct |
56 ms |
1464 KB |
Output is correct |
22 |
Correct |
49 ms |
1272 KB |
Output is correct |
23 |
Correct |
51 ms |
1272 KB |
Output is correct |
24 |
Correct |
52 ms |
1272 KB |
Output is correct |
25 |
Correct |
60 ms |
1400 KB |
Output is correct |
26 |
Correct |
54 ms |
1356 KB |
Output is correct |
27 |
Correct |
56 ms |
1272 KB |
Output is correct |
28 |
Correct |
60 ms |
1460 KB |
Output is correct |
29 |
Correct |
52 ms |
1272 KB |
Output is correct |
30 |
Correct |
39 ms |
1152 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
304 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
256 KB |
Output is correct |
16 |
Correct |
18 ms |
612 KB |
Output is correct |
17 |
Correct |
19 ms |
640 KB |
Output is correct |
18 |
Correct |
19 ms |
640 KB |
Output is correct |
19 |
Correct |
19 ms |
768 KB |
Output is correct |
20 |
Correct |
9 ms |
512 KB |
Output is correct |
21 |
Correct |
75 ms |
1272 KB |
Output is correct |
22 |
Correct |
75 ms |
1272 KB |
Output is correct |
23 |
Correct |
71 ms |
1272 KB |
Output is correct |
24 |
Correct |
85 ms |
1272 KB |
Output is correct |
25 |
Correct |
68 ms |
1272 KB |
Output is correct |
26 |
Correct |
79 ms |
1416 KB |
Output is correct |
27 |
Correct |
69 ms |
1400 KB |
Output is correct |
28 |
Correct |
65 ms |
1344 KB |
Output is correct |
29 |
Correct |
67 ms |
1272 KB |
Output is correct |
30 |
Correct |
35 ms |
1152 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |