#include <bits/stdc++.h>
#include "gap.h"
#define long long long
using namespace std;
long MX = 1e18;
long findGap(int T, int N) {
long mn, mx;
if(T == 2) {
MinMax(0, MX, &mn, &mx);
long sz = (mx-mn+N-2) / (N-1);
long ans = sz;
long pv = mn;
long z = mx;
long p = mn;
while(p <= z) {
MinMax(p, p+sz, &mn, &mx);
if(mn != -1) {
ans = max(ans, mn - pv);
pv = mx;
}
p += sz+1;
}
return ans;
} else {
vector<long> vec;
long l = 0, r = MX;
while(vec.size() < N) {
MinMax(l, r, &mn, &mx);
if(mn != -1) vec.emplace_back(mn);
if(mn != mx) vec.emplace_back(mx);
l = mn+1, r = mx-1;
}
sort(vec.begin(), vec.end());
long ans = 0;
for(int i = 1; i < N; ++i) ans = max(ans, vec[i] - vec[i-1]);
return ans;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(vec.size() < N) {
~~~~~~~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
14 ms |
896 KB |
Output is correct |
17 |
Correct |
14 ms |
1024 KB |
Output is correct |
18 |
Correct |
14 ms |
896 KB |
Output is correct |
19 |
Correct |
14 ms |
896 KB |
Output is correct |
20 |
Correct |
11 ms |
1024 KB |
Output is correct |
21 |
Correct |
51 ms |
2288 KB |
Output is correct |
22 |
Correct |
50 ms |
2288 KB |
Output is correct |
23 |
Correct |
49 ms |
2288 KB |
Output is correct |
24 |
Correct |
50 ms |
2316 KB |
Output is correct |
25 |
Correct |
43 ms |
2288 KB |
Output is correct |
26 |
Correct |
51 ms |
2288 KB |
Output is correct |
27 |
Correct |
50 ms |
2288 KB |
Output is correct |
28 |
Correct |
50 ms |
2288 KB |
Output is correct |
29 |
Correct |
51 ms |
2268 KB |
Output is correct |
30 |
Correct |
38 ms |
2288 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
300 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
17 ms |
616 KB |
Output is correct |
17 |
Correct |
16 ms |
512 KB |
Output is correct |
18 |
Correct |
17 ms |
512 KB |
Output is correct |
19 |
Correct |
17 ms |
640 KB |
Output is correct |
20 |
Correct |
9 ms |
512 KB |
Output is correct |
21 |
Correct |
61 ms |
1144 KB |
Output is correct |
22 |
Correct |
64 ms |
1144 KB |
Output is correct |
23 |
Correct |
62 ms |
1144 KB |
Output is correct |
24 |
Correct |
60 ms |
1152 KB |
Output is correct |
25 |
Correct |
62 ms |
1308 KB |
Output is correct |
26 |
Correct |
64 ms |
1272 KB |
Output is correct |
27 |
Correct |
61 ms |
1144 KB |
Output is correct |
28 |
Correct |
61 ms |
1144 KB |
Output is correct |
29 |
Correct |
62 ms |
1196 KB |
Output is correct |
30 |
Correct |
31 ms |
1148 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |