#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
set<long long> a;
vector<long long> b;
void recur(long long l, long long r) {
if (r-l <= 1) {
long long tmpl, tmpr;
MinMax(l, r, &tmpl, &tmpr);
if (tmpl == -1) return;
a.insert(tmpl);a.insert(tmpr);
return;
}
long long m = l + (r-l)/2;
long long tmpl, tmpr;
MinMax(l, m-1, &tmpl, &tmpr);
if (tmpl != -1) {
a.insert(tmpl);a.insert(tmpr);
if (tmpl + 1 < tmpr) {
recur(tmpl+1, tmpr-1);
}
}
MinMax(m, r, &tmpl, &tmpr);
if (tmpl != -1) {
a.insert(tmpl);a.insert(tmpr);
if (tmpl + 1 < tmpr) {
recur(tmpl+1, tmpr-1);
}
}
}
long long findGap(int T, int N) {
if (T == 1) {
long long mn = 0, mx = 1e18;
for (int i=0;i<(N+1)/2;i++) {
long long tmn, tmx;
MinMax(mn, mx, &tmn, &tmx);
if (tmn == -1) break;
a.insert(tmn);
a.insert(tmx);
mn = tmn+1;mx = tmx-1;
}
}
else recur(0, (long long)1e18);
for (long long x:a)b.push_back(x);
long long dif = 0;
for (int i=1;i<N;i++) {
dif = max(dif, b[i] - b[i-1]);
}
return dif;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
0 ms |
2392 KB |
Output is correct |
7 |
Correct |
0 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
0 ms |
2392 KB |
Output is correct |
10 |
Correct |
0 ms |
2392 KB |
Output is correct |
11 |
Correct |
2 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2644 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
11 ms |
4076 KB |
Output is correct |
17 |
Correct |
10 ms |
4056 KB |
Output is correct |
18 |
Correct |
10 ms |
4056 KB |
Output is correct |
19 |
Correct |
17 ms |
4056 KB |
Output is correct |
20 |
Correct |
8 ms |
4056 KB |
Output is correct |
21 |
Correct |
51 ms |
8616 KB |
Output is correct |
22 |
Correct |
40 ms |
8648 KB |
Output is correct |
23 |
Correct |
40 ms |
8652 KB |
Output is correct |
24 |
Correct |
40 ms |
8660 KB |
Output is correct |
25 |
Correct |
62 ms |
8652 KB |
Output is correct |
26 |
Correct |
46 ms |
8652 KB |
Output is correct |
27 |
Correct |
43 ms |
8516 KB |
Output is correct |
28 |
Correct |
49 ms |
8652 KB |
Output is correct |
29 |
Correct |
47 ms |
8480 KB |
Output is correct |
30 |
Correct |
32 ms |
8652 KB |
Output is correct |
31 |
Correct |
0 ms |
2392 KB |
Output is correct |
32 |
Correct |
0 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
6 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
7 |
Partially correct |
0 ms |
2392 KB |
Partially correct |
8 |
Partially correct |
0 ms |
2392 KB |
Partially correct |
9 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
10 |
Partially correct |
0 ms |
2392 KB |
Partially correct |
11 |
Partially correct |
2 ms |
2392 KB |
Partially correct |
12 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
13 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
14 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
15 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
16 |
Partially correct |
12 ms |
4020 KB |
Partially correct |
17 |
Partially correct |
13 ms |
4056 KB |
Partially correct |
18 |
Partially correct |
12 ms |
4000 KB |
Partially correct |
19 |
Partially correct |
11 ms |
4056 KB |
Partially correct |
20 |
Partially correct |
8 ms |
4056 KB |
Partially correct |
21 |
Partially correct |
50 ms |
8708 KB |
Partially correct |
22 |
Partially correct |
54 ms |
8652 KB |
Partially correct |
23 |
Partially correct |
55 ms |
8484 KB |
Partially correct |
24 |
Partially correct |
50 ms |
8576 KB |
Partially correct |
25 |
Partially correct |
48 ms |
8652 KB |
Partially correct |
26 |
Partially correct |
63 ms |
8652 KB |
Partially correct |
27 |
Partially correct |
46 ms |
8652 KB |
Partially correct |
28 |
Partially correct |
57 ms |
8652 KB |
Partially correct |
29 |
Partially correct |
59 ms |
8652 KB |
Partially correct |
30 |
Partially correct |
38 ms |
8624 KB |
Partially correct |
31 |
Partially correct |
0 ms |
2392 KB |
Partially correct |
32 |
Partially correct |
0 ms |
2392 KB |
Partially correct |