# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1076891 |
2024-08-26T18:01:56 Z |
TFF |
Gap (APIO16_gap) |
C++17 |
|
47 ms |
3296 KB |
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
const long long MX = 1000000000000000000;
long long mn, mx;
int n;
long long findGap(int t, int N) {
n = N;
if (t == 1) {
long long left, right;
left = 0;
right = MX;
vector<long long> arr1, arr2;
for (int i = 0; i < (n + 1) / 2; i++) {
MinMax(left, right, &mn, &mx);
arr1.push_back(mn);
arr2.push_back(mx);
left = mn + 1;
right = mx - 1;
}
long long ans = arr2.back() - arr1.back();
for (int i = 0; i < (int)arr1.size() - 1; i++) {
ans = max(ans, arr1[i + 1] - arr1[i]);
ans = max(ans, arr2[i] - arr2[i + 1]);
}
return ans;
}
MinMax(0, MX, &mn, &mx);
long long left = mn;
long long right = mx;
long long delta = (mx - mn + n - 2) / (n - 1);
vector<long long> pos;
pos.push_back(left);
for (int i = 0; i < n - 1; i++) {
MinMax(left + i * delta + 1, min(left + (i + 1) * delta, right), &mn, &mx);
if (mn != -1) {
pos.push_back(mn);
pos.push_back(mx);
}
}
pos.push_back(right);
long long ans = 0;
for (int i = 0; i < (int)pos.size(); i++) {
ans = max(ans, pos[i + 1] - pos[i]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
372 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 |
9 ms |
752 KB |
Output is correct |
17 |
Correct |
7 ms |
856 KB |
Output is correct |
18 |
Correct |
9 ms |
856 KB |
Output is correct |
19 |
Correct |
10 ms |
840 KB |
Output is correct |
20 |
Correct |
6 ms |
856 KB |
Output is correct |
21 |
Correct |
35 ms |
1980 KB |
Output is correct |
22 |
Correct |
30 ms |
1920 KB |
Output is correct |
23 |
Correct |
39 ms |
2092 KB |
Output is correct |
24 |
Correct |
30 ms |
2124 KB |
Output is correct |
25 |
Correct |
32 ms |
2136 KB |
Output is correct |
26 |
Correct |
30 ms |
2024 KB |
Output is correct |
27 |
Correct |
31 ms |
2156 KB |
Output is correct |
28 |
Correct |
34 ms |
2040 KB |
Output is correct |
29 |
Correct |
28 ms |
2100 KB |
Output is correct |
30 |
Correct |
31 ms |
1924 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
416 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
352 KB |
Output is correct |
6 |
Correct |
1 ms |
340 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 |
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 |
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 |
9 ms |
1012 KB |
Output is correct |
17 |
Correct |
10 ms |
980 KB |
Output is correct |
18 |
Correct |
9 ms |
980 KB |
Output is correct |
19 |
Correct |
9 ms |
980 KB |
Output is correct |
20 |
Runtime error |
5 ms |
600 KB |
Execution failed because the return code was nonzero |
21 |
Correct |
38 ms |
2372 KB |
Output is correct |
22 |
Correct |
40 ms |
2332 KB |
Output is correct |
23 |
Correct |
35 ms |
2256 KB |
Output is correct |
24 |
Correct |
47 ms |
2256 KB |
Output is correct |
25 |
Correct |
44 ms |
3296 KB |
Output is correct |
26 |
Correct |
44 ms |
2248 KB |
Output is correct |
27 |
Correct |
39 ms |
2168 KB |
Output is correct |
28 |
Correct |
45 ms |
2248 KB |
Output is correct |
29 |
Correct |
37 ms |
2268 KB |
Output is correct |
30 |
Runtime error |
24 ms |
1624 KB |
Execution failed because the return code was nonzero |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |