#include <bits/stdc++.h>
#include "gap.h"
#define DEBUG 0
using namespace std;
const long long INF = 1e18;
long long findGap(int T, int N) {
vector <long long> a;
if(T == 1) {
a.resize(N);
MinMax(0, INF, &a[0], &a[N - 1]);
int l = 1, r = N - 2;
while(l <= r) {
MinMax(a[l - 1] + 1, a[r + 1] - 1, &a[l], &a[r]);
l++;
r--;
}
}
else {
long long L, R;
MinMax(0, INF, &L, &R);
long long minimum = (R - L + N - 2) / (N - 1);
a.push_back(L);
L++;
while(L < R) {
long long nL, nR;
MinMax(L, min(L + minimum, R - 1), &nL, &nR);
if(nL != -1 and nR != -1) {
a.push_back(nL);
a.push_back(nR);
}
L = min(L + minimum, R - 1) + 1;
}
a.push_back(R);
}
long long ans = 0;
for(int i = 1; i < a.size(); i++) {
ans = max(ans, a[i] - a[i - 1]);
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for(int i = 1; i < a.size(); i++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
0 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
9 ms |
712 KB |
Output is correct |
17 |
Correct |
9 ms |
676 KB |
Output is correct |
18 |
Correct |
10 ms |
712 KB |
Output is correct |
19 |
Correct |
9 ms |
712 KB |
Output is correct |
20 |
Correct |
7 ms |
712 KB |
Output is correct |
21 |
Correct |
36 ms |
1804 KB |
Output is correct |
22 |
Correct |
35 ms |
1856 KB |
Output is correct |
23 |
Correct |
36 ms |
1844 KB |
Output is correct |
24 |
Correct |
43 ms |
1812 KB |
Output is correct |
25 |
Correct |
29 ms |
1800 KB |
Output is correct |
26 |
Correct |
36 ms |
1812 KB |
Output is correct |
27 |
Correct |
35 ms |
1816 KB |
Output is correct |
28 |
Correct |
35 ms |
1860 KB |
Output is correct |
29 |
Correct |
42 ms |
1820 KB |
Output is correct |
30 |
Correct |
33 ms |
1832 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
0 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
320 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
13 ms |
872 KB |
Output is correct |
17 |
Correct |
12 ms |
840 KB |
Output is correct |
18 |
Correct |
12 ms |
856 KB |
Output is correct |
19 |
Correct |
14 ms |
840 KB |
Output is correct |
20 |
Correct |
6 ms |
456 KB |
Output is correct |
21 |
Correct |
57 ms |
2228 KB |
Output is correct |
22 |
Correct |
51 ms |
2232 KB |
Output is correct |
23 |
Correct |
56 ms |
2128 KB |
Output is correct |
24 |
Correct |
50 ms |
2156 KB |
Output is correct |
25 |
Correct |
46 ms |
3192 KB |
Output is correct |
26 |
Correct |
50 ms |
2168 KB |
Output is correct |
27 |
Correct |
50 ms |
2232 KB |
Output is correct |
28 |
Correct |
59 ms |
2356 KB |
Output is correct |
29 |
Correct |
50 ms |
2192 KB |
Output is correct |
30 |
Correct |
24 ms |
1456 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |