# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1018867 |
2024-07-10T10:24:41 Z |
coolboy19521 |
Gap (APIO16_gap) |
C++17 |
|
2000 ms |
524288 KB |
#include "bits/stdc++.h"
#include "gap.h"
using namespace std;
const int sz = 1e5 + 5;
long long a[sz];
long long findGap(int T, int N)
{
if (1 == T) {
long long mn, mx;
MinMax(0, 1e18, &mn, &mx);
a[1] = mn;
a[N] = mx;
for (int i = 1; i <= (N+1)/2-1; i ++) {
MinMax(mn+1, mx-1, &mn, &mx);
a[i+1] = mn;
a[N - i] = mx;
}
long long gp = 0;
for (int i = 1; i <= N-1; i ++)
gp = max(gp, a[i+1] - a[i]);
return gp;
} else {
long long mn, mx;
MinMax(0, 1e18, &mn, &mx);
vector<long long> b = {mn, mx};
long long k = (mx - mn + N-2) / (N-1);
while (N != (int) b.size()) {
long long d = mn + k+1;
MinMax(mn+1, min(b[1]-1, mn + k+1), &mn, &mx);
if (-1 == mn) {
mx = d;
continue;
} else if (mn == mx)
b.push_back(mn);
else {
b.push_back(mn);
b.push_back(mx);
while (true) {
if (mn+1>mx-1) break;
MinMax(mn+1, mx-1, &mn, &mx);
if (-1 == mn) break;
if (mn == mx) {
b.push_back(mn);
break;
} else {
b.push_back(mn);
b.push_back(mx);
}
}
mx = d;
}
mn = mx + 1;
}
sort(begin(b), end(b));
long long gp = 0;
for (int i = 0; i < N-1; i ++)
gp = max(gp, b[i+1] - b[i]);
return gp;
}
return 0;
}
# |
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 |
1 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 |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
7 ms |
600 KB |
Output is correct |
17 |
Correct |
7 ms |
600 KB |
Output is correct |
18 |
Correct |
10 ms |
600 KB |
Output is correct |
19 |
Correct |
10 ms |
796 KB |
Output is correct |
20 |
Correct |
8 ms |
604 KB |
Output is correct |
21 |
Correct |
34 ms |
1948 KB |
Output is correct |
22 |
Correct |
35 ms |
1896 KB |
Output is correct |
23 |
Correct |
41 ms |
2032 KB |
Output is correct |
24 |
Correct |
37 ms |
1776 KB |
Output is correct |
25 |
Correct |
27 ms |
1880 KB |
Output is correct |
26 |
Correct |
35 ms |
1860 KB |
Output is correct |
27 |
Correct |
31 ms |
1904 KB |
Output is correct |
28 |
Correct |
28 ms |
1996 KB |
Output is correct |
29 |
Correct |
30 ms |
1868 KB |
Output is correct |
30 |
Correct |
20 ms |
1800 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 |
Execution timed out |
3087 ms |
344 KB |
Time limit exceeded |
3 |
Execution timed out |
3080 ms |
348 KB |
Time limit exceeded |
4 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
5 |
Correct |
0 ms |
356 KB |
Output is correct |
6 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
7 |
Execution timed out |
2037 ms |
524288 KB |
Time limit exceeded |
8 |
Execution timed out |
3035 ms |
344 KB |
Time limit exceeded |
9 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
11 |
Execution timed out |
3079 ms |
344 KB |
Time limit exceeded |
12 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Execution timed out |
3088 ms |
600 KB |
Time limit exceeded |
17 |
Execution timed out |
3026 ms |
600 KB |
Time limit exceeded |
18 |
Execution timed out |
3019 ms |
600 KB |
Time limit exceeded |
19 |
Execution timed out |
3063 ms |
560 KB |
Time limit exceeded |
20 |
Execution timed out |
3055 ms |
263472 KB |
Time limit exceeded |
21 |
Execution timed out |
3099 ms |
132696 KB |
Time limit exceeded |
22 |
Execution timed out |
3042 ms |
1112 KB |
Time limit exceeded |
23 |
Execution timed out |
3053 ms |
1112 KB |
Time limit exceeded |
24 |
Execution timed out |
3059 ms |
264016 KB |
Time limit exceeded |
25 |
Correct |
35 ms |
2248 KB |
Output is correct |
26 |
Incorrect |
41 ms |
2248 KB |
Output isn't correct |
27 |
Incorrect |
37 ms |
2248 KB |
Output isn't correct |
28 |
Incorrect |
52 ms |
2248 KB |
Output isn't correct |
29 |
Execution timed out |
3070 ms |
1112 KB |
Time limit exceeded |
30 |
Execution timed out |
3077 ms |
264020 KB |
Time limit exceeded |
31 |
Runtime error |
1162 ms |
524288 KB |
Execution killed with signal 9 |
32 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |