#include "gap.h"
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdlib>
typedef long long ll;
using namespace std;
const ll MX = 1000000000000000000LL;
long long findGap(int T, int N){
if(T == 2){
ll mi, mx; MinMax(0, MX, &mi, &mx);
ll L, R, len = mx - mi + 1;
ll blok = len / N;
ll lst = mi, ans = blok;
for(ll i = mi + 1;i < mx;){
MinMax(i, i + ans - 1, &L, &R); i += ans;
if(L != -1){
ans = max(ans, L - lst);
lst = R;
}
}
ans = max(ans, mx - lst);
return ans;
}
else{
ll L = 0, R = MX;
vector < ll > V;
while(V.size() != N){
ll nw1, nw2;
MinMax(L, R, &nw1, &nw2);
V.push_back(nw1);
if(nw1 != nw2)
V.push_back(nw2);
L = nw1 + 1, R = nw2 - 1;
}
sort(V.begin(), V.end());
ll ans = 0;
for(int i = 1;i < V.size();i++)
ans = max(ans, V[i] - V[i - 1]);
return ans;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:32:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(V.size() != N){
~~~~~~~~~^~~~
gap.cpp:42:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1;i < V.size();i++)
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
356 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 |
2 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 |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
15 ms |
1280 KB |
Output is correct |
17 |
Correct |
16 ms |
1280 KB |
Output is correct |
18 |
Correct |
15 ms |
1280 KB |
Output is correct |
19 |
Correct |
14 ms |
1280 KB |
Output is correct |
20 |
Correct |
11 ms |
1024 KB |
Output is correct |
21 |
Correct |
50 ms |
4016 KB |
Output is correct |
22 |
Correct |
50 ms |
4080 KB |
Output is correct |
23 |
Correct |
50 ms |
3980 KB |
Output is correct |
24 |
Correct |
50 ms |
4080 KB |
Output is correct |
25 |
Correct |
44 ms |
3444 KB |
Output is correct |
26 |
Correct |
50 ms |
4080 KB |
Output is correct |
27 |
Correct |
52 ms |
3980 KB |
Output is correct |
28 |
Correct |
58 ms |
4080 KB |
Output is correct |
29 |
Correct |
54 ms |
4208 KB |
Output is correct |
30 |
Correct |
40 ms |
2936 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
256 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 |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
9 ms |
896 KB |
Output is correct |
17 |
Correct |
9 ms |
896 KB |
Output is correct |
18 |
Correct |
9 ms |
896 KB |
Output is correct |
19 |
Correct |
9 ms |
896 KB |
Output is correct |
20 |
Correct |
6 ms |
640 KB |
Output is correct |
21 |
Correct |
29 ms |
2808 KB |
Output is correct |
22 |
Correct |
29 ms |
2808 KB |
Output is correct |
23 |
Correct |
29 ms |
2836 KB |
Output is correct |
24 |
Correct |
30 ms |
2816 KB |
Output is correct |
25 |
Correct |
55 ms |
2176 KB |
Output is correct |
26 |
Correct |
29 ms |
2808 KB |
Output is correct |
27 |
Correct |
30 ms |
2936 KB |
Output is correct |
28 |
Correct |
32 ms |
2808 KB |
Output is correct |
29 |
Correct |
30 ms |
2904 KB |
Output is correct |
30 |
Correct |
22 ms |
1664 KB |
Output is correct |
31 |
Correct |
2 ms |
256 KB |
Output is correct |
32 |
Correct |
2 ms |
256 KB |
Output is correct |