#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
long long mn = 0, mx = 0;
set<long long> st;
void gen(long long l, long long r)
{
if (l > r)
return;
MinMax(l, r, &mn, &mx);
if (mn == -1)
return;
st.insert(mn);
st.insert(mx);
if (mn == mx)
return;
l = mn + 1, r = mx - 1;
long long m = l + (r - l) / 2;
gen(l, m);
gen(m + 1, r);
}
long long findGap(int T, int N)
{
long long ans = 1;
if (T == 2)
{
gen(0, 1e18);
}
else
{
long long l = 0, r = 1e18;
while (1)
{
MinMax(l, r, &mn, &mx);
if (mn == -1)
break;
st.insert(mn);
st.insert(mx);
l = mn + 1, r = mx - 1;
if (mn == mx || (long long)st.size() >= N)
break;
}
}
long long last = *st.begin();
for (auto &i : st)
ans = max(ans, i - last), last = i;
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
388 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
9 ms |
1700 KB |
Output is correct |
17 |
Correct |
10 ms |
1792 KB |
Output is correct |
18 |
Correct |
10 ms |
1720 KB |
Output is correct |
19 |
Correct |
9 ms |
1624 KB |
Output is correct |
20 |
Correct |
9 ms |
1652 KB |
Output is correct |
21 |
Correct |
40 ms |
5712 KB |
Output is correct |
22 |
Correct |
40 ms |
5720 KB |
Output is correct |
23 |
Correct |
43 ms |
5868 KB |
Output is correct |
24 |
Correct |
40 ms |
5964 KB |
Output is correct |
25 |
Correct |
36 ms |
5720 KB |
Output is correct |
26 |
Correct |
41 ms |
5752 KB |
Output is correct |
27 |
Correct |
42 ms |
5820 KB |
Output is correct |
28 |
Correct |
40 ms |
5712 KB |
Output is correct |
29 |
Correct |
39 ms |
5712 KB |
Output is correct |
30 |
Correct |
45 ms |
5712 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Partially correct |
0 ms |
428 KB |
Partially correct |
3 |
Partially correct |
0 ms |
344 KB |
Partially correct |
4 |
Partially correct |
0 ms |
344 KB |
Partially correct |
5 |
Partially correct |
0 ms |
344 KB |
Partially correct |
6 |
Partially correct |
0 ms |
344 KB |
Partially correct |
7 |
Partially correct |
0 ms |
344 KB |
Partially correct |
8 |
Partially correct |
0 ms |
344 KB |
Partially correct |
9 |
Partially correct |
0 ms |
344 KB |
Partially correct |
10 |
Partially correct |
0 ms |
344 KB |
Partially correct |
11 |
Partially correct |
1 ms |
344 KB |
Partially correct |
12 |
Partially correct |
1 ms |
344 KB |
Partially correct |
13 |
Partially correct |
1 ms |
344 KB |
Partially correct |
14 |
Partially correct |
1 ms |
344 KB |
Partially correct |
15 |
Partially correct |
1 ms |
344 KB |
Partially correct |
16 |
Partially correct |
11 ms |
1592 KB |
Partially correct |
17 |
Partially correct |
16 ms |
1624 KB |
Partially correct |
18 |
Partially correct |
11 ms |
1624 KB |
Partially correct |
19 |
Partially correct |
12 ms |
1624 KB |
Partially correct |
20 |
Partially correct |
10 ms |
1600 KB |
Partially correct |
21 |
Partially correct |
56 ms |
5712 KB |
Partially correct |
22 |
Partially correct |
54 ms |
5712 KB |
Partially correct |
23 |
Partially correct |
49 ms |
5712 KB |
Partially correct |
24 |
Partially correct |
55 ms |
5712 KB |
Partially correct |
25 |
Partially correct |
55 ms |
5848 KB |
Partially correct |
26 |
Partially correct |
50 ms |
5712 KB |
Partially correct |
27 |
Partially correct |
51 ms |
5756 KB |
Partially correct |
28 |
Partially correct |
51 ms |
5712 KB |
Partially correct |
29 |
Partially correct |
58 ms |
5864 KB |
Partially correct |
30 |
Partially correct |
48 ms |
5712 KB |
Partially correct |
31 |
Partially correct |
1 ms |
344 KB |
Partially correct |
32 |
Partially correct |
1 ms |
344 KB |
Partially correct |