# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
793228 |
2023-07-25T16:15:21 Z |
kingfran1907 |
Gap (APIO16_gap) |
C++14 |
|
41 ms |
1160 KB |
#include "gap.h"
#include <algorithm>
typedef long long llint;
const llint maxn = 2e18;
using namespace std;
long long findGap(int t, int n) {
llint sol = 0;
if (t == 1) {
llint a, b;
MinMax(0, maxn, &a, &b);
while (n >= 2) {
if (n == 2) {sol = max(sol, b - a); break;}
n -= 2;
llint ta, tb;
MinMax(a + 1, b - 1, &ta, &tb);
sol = max(sol, max(ta - a, b - tb));
a = ta, b = tb;
}
} else {
llint a, b;
MinMax(0, maxn, &a, &b);
llint delta = b - a;
llint mini = (delta + n - 1) / n;
llint las = a;
for (llint t = a + 1; t < b; t += mini) {
llint ta, tb;
if (t + mini >= b) {
if (t >= b - 1) break;
MinMax(t, b - 1, &ta, &tb);
} else MinMax(t, t + mini - 1, &ta, &tb);
if (ta > -1) {
sol = max(sol, ta - las);
las = tb;
}
}
sol = max(sol, b - las);
}
return sol;
}
# |
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 |
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 |
228 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 |
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 |
8 ms |
464 KB |
Output is correct |
17 |
Correct |
7 ms |
408 KB |
Output is correct |
18 |
Correct |
7 ms |
492 KB |
Output is correct |
19 |
Correct |
7 ms |
488 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
29 ms |
1076 KB |
Output is correct |
22 |
Correct |
27 ms |
1044 KB |
Output is correct |
23 |
Correct |
35 ms |
1056 KB |
Output is correct |
24 |
Correct |
29 ms |
1032 KB |
Output is correct |
25 |
Correct |
25 ms |
1052 KB |
Output is correct |
26 |
Correct |
28 ms |
968 KB |
Output is correct |
27 |
Correct |
34 ms |
1040 KB |
Output is correct |
28 |
Correct |
29 ms |
944 KB |
Output is correct |
29 |
Correct |
27 ms |
1048 KB |
Output is correct |
30 |
Correct |
24 ms |
976 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 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 |
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 |
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 |
320 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 |
11 ms |
464 KB |
Output is correct |
17 |
Correct |
11 ms |
496 KB |
Output is correct |
18 |
Correct |
10 ms |
492 KB |
Output is correct |
19 |
Correct |
10 ms |
464 KB |
Output is correct |
20 |
Correct |
5 ms |
464 KB |
Output is correct |
21 |
Correct |
39 ms |
1032 KB |
Output is correct |
22 |
Correct |
40 ms |
980 KB |
Output is correct |
23 |
Correct |
40 ms |
1160 KB |
Output is correct |
24 |
Correct |
41 ms |
976 KB |
Output is correct |
25 |
Correct |
38 ms |
952 KB |
Output is correct |
26 |
Correct |
41 ms |
976 KB |
Output is correct |
27 |
Correct |
40 ms |
1044 KB |
Output is correct |
28 |
Correct |
40 ms |
1044 KB |
Output is correct |
29 |
Correct |
40 ms |
1060 KB |
Output is correct |
30 |
Correct |
23 ms |
1076 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |