#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> llp;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#include "gap.h"
set<ll> S;
ll subtask1(int N) {
//cerr << N << endl;
ll l = 0, r = 1e18+1;
ll q, w;
while (N > 0) {
MinMax(l, r, &q, &w);
//cerr << q << w << endl;
S.insert(q); S.insert(w);
l = q+1;
r = w-1;
N -= 2;
}
set<ll>::iterator it = S.begin();
it++;
ll best = 0;
for (; it != S.end(); it++) {
set<ll>::iterator it2 = it;
it2--;
best = max(best, (*it) - (*it2));
}
return best;
}
void func(ll l, ll r) {
if (l > r) return;
ll q, w;
MinMax(l, r, &q, &w);
if (q == -1) return;
S.insert(q); S.insert(w);
if (q == w) return;
int mid = (q+w)/2;
if (q+1 != mid) func(q+1, mid);
if (mid+1 != w-1) func(mid+1, w-1);
}
ll subtask2(int N) {
func(0, 1e18);
set<ll>::iterator it = S.begin();
/*set<ll>::iterator dbgit = it;
while (dbgit != S.end()) {
cerr << *dbgit << endl;
dbgit++;
}*/
it++;
ll best = 0;
for (; it != S.end(); it++) {
set<ll>::iterator it2 = it;
it2--;
best = max(best, (*it) - (*it2));
}
return best;
}
long long findGap(int T, int N)
{
if (T == 1) return subtask1(N);
else return subtask2(N);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5148 KB |
Output is correct |
2 |
Correct |
0 ms |
5148 KB |
Output is correct |
3 |
Correct |
0 ms |
5148 KB |
Output is correct |
4 |
Correct |
0 ms |
5148 KB |
Output is correct |
5 |
Correct |
0 ms |
5148 KB |
Output is correct |
6 |
Correct |
0 ms |
5148 KB |
Output is correct |
7 |
Correct |
0 ms |
5148 KB |
Output is correct |
8 |
Correct |
0 ms |
5148 KB |
Output is correct |
9 |
Correct |
0 ms |
5148 KB |
Output is correct |
10 |
Correct |
0 ms |
5148 KB |
Output is correct |
11 |
Correct |
0 ms |
5280 KB |
Output is correct |
12 |
Correct |
0 ms |
5280 KB |
Output is correct |
13 |
Correct |
0 ms |
5280 KB |
Output is correct |
14 |
Correct |
0 ms |
5280 KB |
Output is correct |
15 |
Correct |
0 ms |
5280 KB |
Output is correct |
16 |
Correct |
13 ms |
6336 KB |
Output is correct |
17 |
Correct |
16 ms |
6336 KB |
Output is correct |
18 |
Correct |
16 ms |
6336 KB |
Output is correct |
19 |
Correct |
26 ms |
6336 KB |
Output is correct |
20 |
Correct |
13 ms |
6336 KB |
Output is correct |
21 |
Correct |
76 ms |
9900 KB |
Output is correct |
22 |
Correct |
73 ms |
9900 KB |
Output is correct |
23 |
Correct |
83 ms |
9900 KB |
Output is correct |
24 |
Correct |
79 ms |
9900 KB |
Output is correct |
25 |
Correct |
93 ms |
9900 KB |
Output is correct |
26 |
Correct |
89 ms |
9900 KB |
Output is correct |
27 |
Correct |
93 ms |
9900 KB |
Output is correct |
28 |
Correct |
89 ms |
9900 KB |
Output is correct |
29 |
Correct |
86 ms |
9900 KB |
Output is correct |
30 |
Correct |
83 ms |
9900 KB |
Output is correct |
31 |
Correct |
0 ms |
5148 KB |
Output is correct |
32 |
Correct |
0 ms |
5148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5148 KB |
Output is correct |
2 |
Partially correct |
0 ms |
5148 KB |
Partially correct |
3 |
Partially correct |
0 ms |
5148 KB |
Partially correct |
4 |
Partially correct |
0 ms |
5148 KB |
Partially correct |
5 |
Partially correct |
0 ms |
5148 KB |
Partially correct |
6 |
Partially correct |
0 ms |
5148 KB |
Partially correct |
7 |
Partially correct |
0 ms |
5148 KB |
Partially correct |
8 |
Partially correct |
0 ms |
5148 KB |
Partially correct |
9 |
Partially correct |
0 ms |
5148 KB |
Partially correct |
10 |
Partially correct |
0 ms |
5148 KB |
Partially correct |
11 |
Partially correct |
0 ms |
5280 KB |
Partially correct |
12 |
Partially correct |
0 ms |
5280 KB |
Partially correct |
13 |
Partially correct |
0 ms |
5280 KB |
Partially correct |
14 |
Partially correct |
0 ms |
5280 KB |
Partially correct |
15 |
Partially correct |
59 ms |
5280 KB |
Partially correct |
16 |
Partially correct |
23 ms |
7380 KB |
Partially correct |
17 |
Partially correct |
26 ms |
7384 KB |
Partially correct |
18 |
Partially correct |
26 ms |
7380 KB |
Partially correct |
19 |
Partially correct |
19 ms |
7384 KB |
Partially correct |
20 |
Partially correct |
13 ms |
6204 KB |
Partially correct |
21 |
Incorrect |
103 ms |
14464 KB |
Expected int32, but "5000150000" found |
22 |
Incorrect |
106 ms |
14460 KB |
Expected int32, but "5000150000" found |
23 |
Incorrect |
119 ms |
14468 KB |
Expected int32, but "5000150000" found |
24 |
Incorrect |
103 ms |
14464 KB |
Expected int32, but "5000150000" found |
25 |
Execution timed out |
2000 ms |
9936 KB |
Execution timed out |
26 |
Incorrect |
119 ms |
14460 KB |
Expected int32, but "5000150000" found |
27 |
Incorrect |
139 ms |
14464 KB |
Expected int32, but "5000150000" found |
28 |
Incorrect |
123 ms |
14460 KB |
Expected int32, but "5000150000" found |
29 |
Incorrect |
136 ms |
14460 KB |
Expected int32, but "5000150000" found |
30 |
Partially correct |
69 ms |
9240 KB |
Partially correct |
31 |
Partially correct |
0 ms |
5148 KB |
Partially correct |
32 |
Partially correct |
0 ms |
5148 KB |
Partially correct |