# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
847044 |
2023-09-09T02:51:42 Z |
JooDdae |
Gap (APIO16_gap) |
C++17 |
|
41 ms |
3116 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll findGap(int T, int N) {
ll mn, mx;
MinMax(0, (ll)1e18, &mn, &mx);
ll lmn = mn, lmx = mx, ans = 0;
if(T == 1) {
for(int i=1;i<(N+1)/2;i++) {
MinMax(lmn+1, lmx-1, &mn, &mx);
ans = max({ans, lmx-mx, mn-lmn});
lmn = mn, lmx = mx;
}
return max(ans, lmx-lmn);
}
if(N == 2) return mx-mn;
ll R = mx;
ll gap = mx-mn-1;
ll p = gap / (N-1);
ll cnt = gap % (N-1);
lmx = mn;
for(int i=0;i<N-1;i++) {
ll r = lmn + p + (i < cnt);
MinMax(lmn+1, r, &mn, &mx);
if(mn != -1) ans = max(ans, mn-lmx), lmx = mx;
lmn = r;
}
return max(ans, R-lmx);
}
# |
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 |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
7 ms |
2584 KB |
Output is correct |
17 |
Correct |
7 ms |
2584 KB |
Output is correct |
18 |
Correct |
8 ms |
2584 KB |
Output is correct |
19 |
Correct |
7 ms |
2584 KB |
Output is correct |
20 |
Correct |
6 ms |
2568 KB |
Output is correct |
21 |
Correct |
30 ms |
2788 KB |
Output is correct |
22 |
Correct |
31 ms |
2852 KB |
Output is correct |
23 |
Correct |
29 ms |
2852 KB |
Output is correct |
24 |
Correct |
28 ms |
2856 KB |
Output is correct |
25 |
Correct |
26 ms |
2848 KB |
Output is correct |
26 |
Correct |
29 ms |
2752 KB |
Output is correct |
27 |
Correct |
28 ms |
2860 KB |
Output is correct |
28 |
Correct |
28 ms |
2856 KB |
Output is correct |
29 |
Correct |
28 ms |
3116 KB |
Output is correct |
30 |
Correct |
24 ms |
2848 KB |
Output is correct |
31 |
Correct |
0 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2588 KB |
Output is correct |
16 |
Correct |
10 ms |
2584 KB |
Output is correct |
17 |
Correct |
10 ms |
2584 KB |
Output is correct |
18 |
Correct |
10 ms |
2584 KB |
Output is correct |
19 |
Correct |
10 ms |
2552 KB |
Output is correct |
20 |
Correct |
5 ms |
2572 KB |
Output is correct |
21 |
Correct |
40 ms |
2856 KB |
Output is correct |
22 |
Correct |
40 ms |
2860 KB |
Output is correct |
23 |
Correct |
39 ms |
2856 KB |
Output is correct |
24 |
Correct |
41 ms |
2860 KB |
Output is correct |
25 |
Correct |
38 ms |
2856 KB |
Output is correct |
26 |
Correct |
40 ms |
2848 KB |
Output is correct |
27 |
Correct |
39 ms |
2860 KB |
Output is correct |
28 |
Correct |
39 ms |
2856 KB |
Output is correct |
29 |
Correct |
41 ms |
2860 KB |
Output is correct |
30 |
Correct |
23 ms |
2852 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |