#include <bits/stdc++.h>
#include "gap.h"
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long double, pii> muchie;
const ll NMAX = 100001;
const ll VMAX = 1000001;
const ll INF = (1LL << 60);
const ll MOD = 90000000000000001;
const ll BLOCK = 1000000;
const ll base = 1000000001;
const ll nr_of_bits = 16;
ll a[100002];
long long findGap(int T, int N) {
a[0] = -1;
a[N + 1] = 1e18;
a[N + 1] += 1;
if(T == 1) {
int st = 1, dr = N;
while(st <= dr) {
MinMax(a[st - 1] + 1, a[dr + 1] - 1, &a[st], &a[dr]);
st++;
dr--;
}
ll maxim = 0;
for(int i = 2; i <= N; i++) {
maxim = max(maxim, a[i] - a[i - 1]);
}
return maxim;
}
ll first, last;
MinMax(0, 1e18, &first, &last);
ll BLOCK = last - first - 1 + N - 2;
BLOCK /= (N - 1);
ll ultim = first, maxim = 0;
for(ll i = first + 1; i < last; i += BLOCK) {
ll prim, doi;
MinMax(i, min(i + BLOCK - 1, last - 1), &prim, &doi);
if(ultim != -1 && prim != -1)
maxim = max(maxim, prim - ultim);
if(doi != -1)
ultim = doi;
}
maxim = max(maxim, last - ultim);
return maxim;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
11 ms |
648 KB |
Output is correct |
17 |
Correct |
9 ms |
592 KB |
Output is correct |
18 |
Correct |
9 ms |
716 KB |
Output is correct |
19 |
Correct |
9 ms |
644 KB |
Output is correct |
20 |
Correct |
7 ms |
720 KB |
Output is correct |
21 |
Correct |
36 ms |
1912 KB |
Output is correct |
22 |
Correct |
37 ms |
1832 KB |
Output is correct |
23 |
Correct |
37 ms |
1768 KB |
Output is correct |
24 |
Correct |
37 ms |
1760 KB |
Output is correct |
25 |
Correct |
34 ms |
1864 KB |
Output is correct |
26 |
Correct |
38 ms |
1820 KB |
Output is correct |
27 |
Correct |
35 ms |
1832 KB |
Output is correct |
28 |
Correct |
36 ms |
1752 KB |
Output is correct |
29 |
Correct |
37 ms |
1820 KB |
Output is correct |
30 |
Correct |
33 ms |
1796 KB |
Output is correct |
31 |
Correct |
0 ms |
336 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
2 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 |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
15 ms |
508 KB |
Output is correct |
17 |
Correct |
13 ms |
464 KB |
Output is correct |
18 |
Correct |
12 ms |
504 KB |
Output is correct |
19 |
Correct |
11 ms |
524 KB |
Output is correct |
20 |
Correct |
6 ms |
436 KB |
Output is correct |
21 |
Correct |
50 ms |
1072 KB |
Output is correct |
22 |
Correct |
50 ms |
1088 KB |
Output is correct |
23 |
Correct |
50 ms |
1060 KB |
Output is correct |
24 |
Correct |
50 ms |
1084 KB |
Output is correct |
25 |
Correct |
51 ms |
1088 KB |
Output is correct |
26 |
Correct |
49 ms |
1084 KB |
Output is correct |
27 |
Correct |
50 ms |
1016 KB |
Output is correct |
28 |
Correct |
48 ms |
1060 KB |
Output is correct |
29 |
Correct |
51 ms |
1180 KB |
Output is correct |
30 |
Correct |
28 ms |
1092 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |