#include <bits/stdc++.h>
// #include "grader.cpp"
#include "gap.h"
using namespace std;
typedef long long ll;
set<ll> st;
void recur(ll l, ll r){
if (r < l) return ;
if (r - l <= 1){
MinMax(l, r, &l, &r);
if (l != -1){
st.insert(l);
st.insert(r);
}
return ;
}
ll mid = (l + r) / 2;
ll mn, mx;
MinMax(l, mid, &mn, &mx);
if (mn != -1){
st.insert(mn);
st.insert(mx);
recur(mn + 1, mx - 1);
}
MinMax(mid + 1, r, &mn, &mx);
if (mn != -1){
st.insert(mn);
st.insert(mx);
recur(mn + 1, mx - 1);
}
}
ll findGap(int T, int N){
if (T == 1){
ll mn = 0, mx = 1e18;
while (N > 0){
N -= 2;
MinMax(mn, mx, &mn, &mx);
st.insert(mn);
st.insert(mx);
mn++;
mx--;
}
}
else{
recur(0, 1e18);
}
vector<ll> vec;
for (ll x : st)
vec.push_back(x);
ll res = 0;
for (ll i = 1; i < vec.size(); i ++)
res = max(res, vec[i] - vec[i - 1]);
return res;
}
Compilation message
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:63:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for (ll i = 1; i < vec.size(); i ++)
| ~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
344 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 |
2136 KB |
Output is correct |
17 |
Correct |
9 ms |
2136 KB |
Output is correct |
18 |
Correct |
11 ms |
2136 KB |
Output is correct |
19 |
Correct |
11 ms |
2036 KB |
Output is correct |
20 |
Correct |
9 ms |
2100 KB |
Output is correct |
21 |
Correct |
39 ms |
6856 KB |
Output is correct |
22 |
Correct |
42 ms |
6860 KB |
Output is correct |
23 |
Correct |
49 ms |
6864 KB |
Output is correct |
24 |
Correct |
49 ms |
6860 KB |
Output is correct |
25 |
Correct |
36 ms |
6872 KB |
Output is correct |
26 |
Correct |
41 ms |
6828 KB |
Output is correct |
27 |
Correct |
45 ms |
6860 KB |
Output is correct |
28 |
Correct |
39 ms |
6860 KB |
Output is correct |
29 |
Correct |
40 ms |
6860 KB |
Output is correct |
30 |
Correct |
36 ms |
6860 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 |
Correct |
0 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 |
Partially correct |
0 ms |
592 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 |
1 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 |
12 ms |
2096 KB |
Partially correct |
17 |
Partially correct |
12 ms |
2136 KB |
Partially correct |
18 |
Partially correct |
12 ms |
2136 KB |
Partially correct |
19 |
Partially correct |
12 ms |
2136 KB |
Partially correct |
20 |
Partially correct |
10 ms |
2136 KB |
Partially correct |
21 |
Partially correct |
47 ms |
7008 KB |
Partially correct |
22 |
Partially correct |
49 ms |
6864 KB |
Partially correct |
23 |
Partially correct |
48 ms |
6860 KB |
Partially correct |
24 |
Partially correct |
48 ms |
6860 KB |
Partially correct |
25 |
Partially correct |
43 ms |
6860 KB |
Partially correct |
26 |
Partially correct |
52 ms |
7020 KB |
Partially correct |
27 |
Partially correct |
57 ms |
6860 KB |
Partially correct |
28 |
Partially correct |
46 ms |
6860 KB |
Partially correct |
29 |
Partially correct |
46 ms |
6868 KB |
Partially correct |
30 |
Partially correct |
35 ms |
6860 KB |
Partially correct |
31 |
Partially correct |
0 ms |
344 KB |
Partially correct |
32 |
Partially correct |
0 ms |
344 KB |
Partially correct |