# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
565504 |
2022-05-21T02:24:54 Z |
Spade1 |
Gap (APIO16_gap) |
C++14 |
|
58 ms |
1880 KB |
#include<bits/stdc++.h>
#include "gap.h"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;
const int NN = 1e5 + 10;
ll a[NN];
int cnt = 0;
ll findGap(int T, int N) {
if (T == 1) {
ll mn, mx;
ll l = 0, r = 1e18;
for (ll i = 0; i < (N+1)/2; ++i) {
MinMax(l, r, &mn, &mx);
a[cnt++] = mn;
a[cnt++] = mx;
l = mn+1, r = mx - 1;
}
sort(a, a+N);
ll ans = 0;
for (int i = 1; i <= N; ++i) ans = max(ans, a[i] - a[i-1]);
return ans;
}
else {
ll mn, mx;
MinMax(0, 1e18, &mn, &mx);
ll step = (mx - mn + N - 2)/(N - 1);
ll ans = step;
ll x, y, i = mn, l = mn;
for (; i < mx; i += step+1) {
MinMax(i, i+step, &x, &y);
if (x != -1) {
ans = max(ans, x-l);
l = y;
}
}
return ans;
}
}
# |
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 |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
9 ms |
592 KB |
Output is correct |
17 |
Correct |
10 ms |
720 KB |
Output is correct |
18 |
Correct |
11 ms |
720 KB |
Output is correct |
19 |
Correct |
14 ms |
708 KB |
Output is correct |
20 |
Correct |
9 ms |
720 KB |
Output is correct |
21 |
Correct |
40 ms |
1800 KB |
Output is correct |
22 |
Correct |
40 ms |
1828 KB |
Output is correct |
23 |
Correct |
46 ms |
1880 KB |
Output is correct |
24 |
Correct |
42 ms |
1828 KB |
Output is correct |
25 |
Correct |
44 ms |
1828 KB |
Output is correct |
26 |
Correct |
42 ms |
1868 KB |
Output is correct |
27 |
Correct |
42 ms |
1740 KB |
Output is correct |
28 |
Correct |
50 ms |
1872 KB |
Output is correct |
29 |
Correct |
52 ms |
1836 KB |
Output is correct |
30 |
Correct |
31 ms |
1804 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
1 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 |
1 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 |
1 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 |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
13 ms |
428 KB |
Output is correct |
17 |
Correct |
13 ms |
520 KB |
Output is correct |
18 |
Correct |
14 ms |
508 KB |
Output is correct |
19 |
Correct |
12 ms |
464 KB |
Output is correct |
20 |
Correct |
6 ms |
524 KB |
Output is correct |
21 |
Correct |
53 ms |
1088 KB |
Output is correct |
22 |
Correct |
55 ms |
1088 KB |
Output is correct |
23 |
Correct |
57 ms |
1084 KB |
Output is correct |
24 |
Correct |
49 ms |
1076 KB |
Output is correct |
25 |
Correct |
46 ms |
976 KB |
Output is correct |
26 |
Correct |
58 ms |
976 KB |
Output is correct |
27 |
Correct |
52 ms |
1064 KB |
Output is correct |
28 |
Correct |
51 ms |
1084 KB |
Output is correct |
29 |
Correct |
55 ms |
1088 KB |
Output is correct |
30 |
Correct |
31 ms |
1104 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |