# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1084464 |
2024-09-06T09:30:19 Z |
MMihalev |
Gap (APIO16_gap) |
C++17 |
|
41 ms |
1948 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 1e18;
ll a[100000], j = 0;
ll findGap(int T, int N) {
if (T == 1) {
ll l = 1, r = MAXN;
ll mn, mx;
vector<ll> v;
for (ll i = 0; i < (N + 1) / 2; i++) {
MinMax(l, r, &mn, &mx);
a[j++] = mn;
a[j++] = mx;
l = mn + 1, r = mx - 1;
}
sort(a, a + N);
ll ans = 0;
for (ll i = 0; i < N - 1; i++) ans = max(ans, a[i + 1] - a[i]);
return ans;
} else {
ll mn, mx;
MinMax(1, MAXN, &mn, &mx);
ll step = (mx - mn -1 ) / (N - 1);
ll ans = step, x, y, l = mn, i;
for (i = mn; i + step < mx; i += step + 1) {
MinMax(i, i + step, &x, &y);
if (x != -1) {
ans = max(ans, x - l);
l = y;
}
}
MinMax(i, mx, &x, &y);
if (x != -1) ans = max(ans, x - l);
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 |
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 |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 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 |
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 |
392 KB |
Output is correct |
16 |
Correct |
7 ms |
600 KB |
Output is correct |
17 |
Correct |
7 ms |
600 KB |
Output is correct |
18 |
Correct |
9 ms |
684 KB |
Output is correct |
19 |
Correct |
7 ms |
600 KB |
Output is correct |
20 |
Correct |
6 ms |
600 KB |
Output is correct |
21 |
Correct |
28 ms |
1872 KB |
Output is correct |
22 |
Correct |
29 ms |
1872 KB |
Output is correct |
23 |
Correct |
29 ms |
1872 KB |
Output is correct |
24 |
Correct |
29 ms |
1880 KB |
Output is correct |
25 |
Correct |
25 ms |
1880 KB |
Output is correct |
26 |
Correct |
37 ms |
1872 KB |
Output is correct |
27 |
Correct |
30 ms |
1812 KB |
Output is correct |
28 |
Correct |
36 ms |
1880 KB |
Output is correct |
29 |
Correct |
34 ms |
1948 KB |
Output is correct |
30 |
Correct |
23 ms |
1760 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 |
Partially correct |
0 ms |
344 KB |
Partially correct |
2 |
Correct |
1 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 |
Partially correct |
0 ms |
344 KB |
Partially correct |
6 |
Correct |
0 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 |
0 ms |
376 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 |
Partially correct |
1 ms |
344 KB |
Partially correct |
16 |
Correct |
10 ms |
496 KB |
Output is correct |
17 |
Correct |
9 ms |
600 KB |
Output is correct |
18 |
Correct |
8 ms |
656 KB |
Output is correct |
19 |
Correct |
8 ms |
600 KB |
Output is correct |
20 |
Correct |
5 ms |
600 KB |
Output is correct |
21 |
Correct |
35 ms |
1108 KB |
Output is correct |
22 |
Correct |
34 ms |
1112 KB |
Output is correct |
23 |
Correct |
41 ms |
1112 KB |
Output is correct |
24 |
Correct |
35 ms |
1112 KB |
Output is correct |
25 |
Partially correct |
32 ms |
1180 KB |
Partially correct |
26 |
Correct |
35 ms |
1112 KB |
Output is correct |
27 |
Correct |
34 ms |
1112 KB |
Output is correct |
28 |
Correct |
35 ms |
1112 KB |
Output is correct |
29 |
Correct |
35 ms |
1112 KB |
Output is correct |
30 |
Correct |
27 ms |
1084 KB |
Output is correct |
31 |
Partially correct |
0 ms |
344 KB |
Partially correct |
32 |
Partially correct |
0 ms |
344 KB |
Partially correct |