# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
986768 |
2024-05-21T07:58:47 Z |
siewjh |
Gap (APIO16_gap) |
C++17 |
|
45 ms |
2144 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cdiv(ll a, ll b){
return (a + b - 1) / b;
}
ll findGap(int T, int N){
if (T == 1){
vector<ll> vec(N);
ll lv = 0, rv = 1e18, ans = 0;
for (int l = 0, r = N - 1; l <= r; l++, r--){
MinMax(lv, rv, &vec[l], &vec[r]);
lv = vec[l] + 1; rv = vec[r] - 1;
}
for (int i = 1; i < N; i++) ans = max(ans, vec[i] - vec[i - 1]);
return ans;
}
else{
ll mn, mx; MinMax(0, 1e18, &mn, &mx);
ll gap = cdiv(mx - mn, N - 1), prv = mn, ans = 0;
for (int i = 0; i < N - 1; i++){
ll mnh, mxh; MinMax(mn + gap * i + 1, min(mn + gap * (i + 1), mx), &mnh, &mxh);
if (mnh == -1) continue;
ans = max(ans, mnh - prv);
prv = mxh;
}
return ans;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
8 ms |
640 KB |
Output is correct |
17 |
Correct |
7 ms |
896 KB |
Output is correct |
18 |
Correct |
8 ms |
808 KB |
Output is correct |
19 |
Correct |
8 ms |
640 KB |
Output is correct |
20 |
Correct |
6 ms |
612 KB |
Output is correct |
21 |
Correct |
30 ms |
2144 KB |
Output is correct |
22 |
Correct |
29 ms |
1976 KB |
Output is correct |
23 |
Correct |
29 ms |
1976 KB |
Output is correct |
24 |
Correct |
29 ms |
1980 KB |
Output is correct |
25 |
Correct |
32 ms |
1988 KB |
Output is correct |
26 |
Correct |
29 ms |
1980 KB |
Output is correct |
27 |
Correct |
30 ms |
1960 KB |
Output is correct |
28 |
Correct |
30 ms |
1976 KB |
Output is correct |
29 |
Correct |
29 ms |
1980 KB |
Output is correct |
30 |
Correct |
29 ms |
1956 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
424 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 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 |
596 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
10 ms |
640 KB |
Output is correct |
17 |
Correct |
10 ms |
648 KB |
Output is correct |
18 |
Correct |
10 ms |
644 KB |
Output is correct |
19 |
Correct |
10 ms |
640 KB |
Output is correct |
20 |
Runtime error |
5 ms |
652 KB |
Execution failed because the return code was nonzero |
21 |
Correct |
45 ms |
1220 KB |
Output is correct |
22 |
Correct |
40 ms |
1212 KB |
Output is correct |
23 |
Correct |
40 ms |
1220 KB |
Output is correct |
24 |
Correct |
44 ms |
1136 KB |
Output is correct |
25 |
Correct |
38 ms |
1232 KB |
Output is correct |
26 |
Correct |
43 ms |
1216 KB |
Output is correct |
27 |
Correct |
43 ms |
1440 KB |
Output is correct |
28 |
Correct |
40 ms |
1208 KB |
Output is correct |
29 |
Correct |
41 ms |
1216 KB |
Output is correct |
30 |
Runtime error |
27 ms |
1220 KB |
Execution failed because the return code was nonzero |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |