# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1018878 |
2024-07-10T10:33:46 Z |
coolboy19521 |
Gap (APIO16_gap) |
C++17 |
|
2000 ms |
2248 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;
// cout << mn+1 << ' ' << min(b[1]-1, mn + k+1) << '\n';
int s = mn+1;
int e = min(b[1]-1, mn + k+1);
if (s > e) break;
MinMax(s, e, &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;
// cout << mn+1 << ' ' << mx-1 << '\n';
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;
}
//for (int x : b)
// cout << x << ' ';
// cout << '\n';
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 |
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 |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 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 |
600 KB |
Output is correct |
17 |
Correct |
6 ms |
600 KB |
Output is correct |
18 |
Correct |
6 ms |
800 KB |
Output is correct |
19 |
Correct |
6 ms |
600 KB |
Output is correct |
20 |
Correct |
5 ms |
600 KB |
Output is correct |
21 |
Correct |
25 ms |
1784 KB |
Output is correct |
22 |
Correct |
26 ms |
1868 KB |
Output is correct |
23 |
Correct |
25 ms |
1872 KB |
Output is correct |
24 |
Correct |
26 ms |
1872 KB |
Output is correct |
25 |
Correct |
23 ms |
1824 KB |
Output is correct |
26 |
Correct |
26 ms |
1868 KB |
Output is correct |
27 |
Correct |
36 ms |
1872 KB |
Output is correct |
28 |
Correct |
25 ms |
1872 KB |
Output is correct |
29 |
Correct |
25 ms |
1880 KB |
Output is correct |
30 |
Correct |
21 ms |
1880 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 |
Incorrect |
1 ms |
512 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
7 |
Execution timed out |
3005 ms |
344 KB |
Time limit exceeded |
8 |
Execution timed out |
3066 ms |
344 KB |
Time limit exceeded |
9 |
Execution timed out |
3058 ms |
344 KB |
Time limit exceeded |
10 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
11 |
Execution timed out |
3089 ms |
344 KB |
Time limit exceeded |
12 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
14 |
Execution timed out |
3100 ms |
344 KB |
Time limit exceeded |
15 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
16 |
Execution timed out |
3095 ms |
600 KB |
Time limit exceeded |
17 |
Runtime error |
4 ms |
856 KB |
Execution killed with signal 11 |
18 |
Runtime error |
4 ms |
856 KB |
Execution killed with signal 11 |
19 |
Execution timed out |
3092 ms |
600 KB |
Time limit exceeded |
20 |
Incorrect |
9 ms |
980 KB |
Output isn't correct |
21 |
Execution timed out |
3062 ms |
1116 KB |
Time limit exceeded |
22 |
Execution timed out |
3069 ms |
1112 KB |
Time limit exceeded |
23 |
Execution timed out |
3061 ms |
1112 KB |
Time limit exceeded |
24 |
Runtime error |
13 ms |
2200 KB |
Execution killed with signal 11 |
25 |
Runtime error |
11 ms |
2144 KB |
Execution killed with signal 11 |
26 |
Execution timed out |
3067 ms |
1112 KB |
Time limit exceeded |
27 |
Execution timed out |
3025 ms |
1112 KB |
Time limit exceeded |
28 |
Execution timed out |
3037 ms |
1112 KB |
Time limit exceeded |
29 |
Execution timed out |
3045 ms |
1036 KB |
Time limit exceeded |
30 |
Incorrect |
31 ms |
2248 KB |
Output isn't correct |
31 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |