#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5 + 10;
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))
int N;
ll A[MAXN];
ll findGap (int subtask, int nnn) {
N = nnn;
ll ans = 0;
if (subtask == 1) {
for (int i = 1, j = N; i <= j; i++, j--) {
ll mn, mx;
if (i == 1) {
mn = 0;
mx = 1e18;
} else {
mn = A[i - 1] + 1;
mx = A[j + 1] - 1;
}
MinMax(mn, mx, &mn, &mx);
A[i] = mn;
A[j] = mx;
}
for (int i = 2; i <= N; i++) {
ans = max(ans, A[i] - A[i - 1]);
}
} else {
ll a1, an;
MinMax(0, 1e18, &a1, &an);
ll gap = (an - a1 + (N - 2)) / (N - 1); //gap at least this big
ll pval = a1;
for (ll lt = a1 + 1, rt = a1 + gap; lt <= an; lt += gap, rt += gap) {
ll imn, imx; //interval mn, mx
MinMax(lt, rt, &imn, &imx);
if (imn != -1) {
ans = max(ans, imn - pval);
pval = imx;
}
}
ans = max(ans, an - pval);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
488 KB |
Output is correct |
3 |
Correct |
3 ms |
564 KB |
Output is correct |
4 |
Correct |
3 ms |
564 KB |
Output is correct |
5 |
Correct |
0 ms |
592 KB |
Output is correct |
6 |
Correct |
3 ms |
592 KB |
Output is correct |
7 |
Correct |
3 ms |
592 KB |
Output is correct |
8 |
Correct |
3 ms |
592 KB |
Output is correct |
9 |
Correct |
3 ms |
592 KB |
Output is correct |
10 |
Correct |
3 ms |
592 KB |
Output is correct |
11 |
Correct |
4 ms |
592 KB |
Output is correct |
12 |
Correct |
4 ms |
592 KB |
Output is correct |
13 |
Correct |
4 ms |
664 KB |
Output is correct |
14 |
Correct |
4 ms |
664 KB |
Output is correct |
15 |
Correct |
4 ms |
664 KB |
Output is correct |
16 |
Correct |
21 ms |
1096 KB |
Output is correct |
17 |
Correct |
18 ms |
1096 KB |
Output is correct |
18 |
Correct |
24 ms |
1096 KB |
Output is correct |
19 |
Correct |
21 ms |
1096 KB |
Output is correct |
20 |
Correct |
10 ms |
1096 KB |
Output is correct |
21 |
Correct |
67 ms |
2152 KB |
Output is correct |
22 |
Correct |
81 ms |
2240 KB |
Output is correct |
23 |
Correct |
79 ms |
2280 KB |
Output is correct |
24 |
Correct |
70 ms |
2280 KB |
Output is correct |
25 |
Correct |
64 ms |
2280 KB |
Output is correct |
26 |
Correct |
72 ms |
2280 KB |
Output is correct |
27 |
Correct |
78 ms |
2280 KB |
Output is correct |
28 |
Correct |
79 ms |
2280 KB |
Output is correct |
29 |
Correct |
79 ms |
2280 KB |
Output is correct |
30 |
Correct |
61 ms |
2280 KB |
Output is correct |
31 |
Correct |
3 ms |
2280 KB |
Output is correct |
32 |
Correct |
4 ms |
2280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2280 KB |
Output is correct |
2 |
Correct |
0 ms |
2280 KB |
Output is correct |
3 |
Correct |
3 ms |
2280 KB |
Output is correct |
4 |
Correct |
3 ms |
2280 KB |
Output is correct |
5 |
Correct |
3 ms |
2280 KB |
Output is correct |
6 |
Correct |
3 ms |
2280 KB |
Output is correct |
7 |
Correct |
3 ms |
2280 KB |
Output is correct |
8 |
Correct |
3 ms |
2280 KB |
Output is correct |
9 |
Correct |
3 ms |
2280 KB |
Output is correct |
10 |
Correct |
4 ms |
2280 KB |
Output is correct |
11 |
Correct |
5 ms |
2280 KB |
Output is correct |
12 |
Correct |
3 ms |
2280 KB |
Output is correct |
13 |
Correct |
5 ms |
2280 KB |
Output is correct |
14 |
Correct |
4 ms |
2280 KB |
Output is correct |
15 |
Correct |
4 ms |
2280 KB |
Output is correct |
16 |
Correct |
26 ms |
2280 KB |
Output is correct |
17 |
Correct |
29 ms |
2280 KB |
Output is correct |
18 |
Correct |
31 ms |
2280 KB |
Output is correct |
19 |
Correct |
30 ms |
2280 KB |
Output is correct |
20 |
Correct |
13 ms |
2280 KB |
Output is correct |
21 |
Correct |
107 ms |
2280 KB |
Output is correct |
22 |
Correct |
107 ms |
2280 KB |
Output is correct |
23 |
Correct |
108 ms |
2280 KB |
Output is correct |
24 |
Correct |
110 ms |
2280 KB |
Output is correct |
25 |
Correct |
98 ms |
2280 KB |
Output is correct |
26 |
Correct |
99 ms |
2280 KB |
Output is correct |
27 |
Correct |
103 ms |
2280 KB |
Output is correct |
28 |
Correct |
97 ms |
2280 KB |
Output is correct |
29 |
Correct |
98 ms |
2280 KB |
Output is correct |
30 |
Correct |
59 ms |
2280 KB |
Output is correct |
31 |
Correct |
3 ms |
2280 KB |
Output is correct |
32 |
Correct |
4 ms |
2280 KB |
Output is correct |