#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll findGap(int T, int N)
{
ll mn,mx;
MinMax(0,1LL<<60,&mn,&mx);
vector<ll> a(0);
ll ans=-1;
if (T==1){
a.push_back(mn);a.push_back(mx);
int cnt=N-2;
while (cnt>0){
MinMax(mn+1,mx-1,&mn,&mx);
if (mn>0) a.push_back(mn);
if (mx>0) a.push_back(mx);
cnt-=2;
}
}
else{
ll gmn=mn,gmx=mx,rng=(mx-mn+N-2)/(N-1)+1;
a.push_back(mn);a.push_back(mx);
gmn++;
while (gmn<gmx){
MinMax(gmn,gmn+rng,&mn,&mx);
if (mn!=-1) a.push_back(mn);
if (mx!=-1) a.push_back(mx);
gmn+=rng;
}
}
sort(a.begin(),a.end());
for (int i=1;i<a.size();i++){
ans=max(ans,a[i]-a[i-1]);
}
return ans;
return 0;
}
Compilation message
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:33:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int i=1;i<a.size();i++){
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
10 ms |
888 KB |
Output is correct |
17 |
Correct |
9 ms |
848 KB |
Output is correct |
18 |
Correct |
10 ms |
832 KB |
Output is correct |
19 |
Correct |
10 ms |
812 KB |
Output is correct |
20 |
Correct |
8 ms |
848 KB |
Output is correct |
21 |
Correct |
45 ms |
2200 KB |
Output is correct |
22 |
Correct |
44 ms |
2256 KB |
Output is correct |
23 |
Correct |
41 ms |
2176 KB |
Output is correct |
24 |
Correct |
39 ms |
2204 KB |
Output is correct |
25 |
Correct |
34 ms |
2240 KB |
Output is correct |
26 |
Correct |
45 ms |
2176 KB |
Output is correct |
27 |
Correct |
41 ms |
2208 KB |
Output is correct |
28 |
Correct |
43 ms |
2220 KB |
Output is correct |
29 |
Correct |
38 ms |
2136 KB |
Output is correct |
30 |
Correct |
31 ms |
2236 KB |
Output is correct |
31 |
Correct |
0 ms |
336 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
352 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
12 ms |
892 KB |
Output is correct |
17 |
Correct |
12 ms |
868 KB |
Output is correct |
18 |
Correct |
12 ms |
808 KB |
Output is correct |
19 |
Correct |
13 ms |
848 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
60 ms |
2244 KB |
Output is correct |
22 |
Correct |
51 ms |
2228 KB |
Output is correct |
23 |
Correct |
51 ms |
2240 KB |
Output is correct |
24 |
Correct |
50 ms |
2200 KB |
Output is correct |
25 |
Correct |
51 ms |
3180 KB |
Output is correct |
26 |
Correct |
53 ms |
2240 KB |
Output is correct |
27 |
Correct |
51 ms |
2244 KB |
Output is correct |
28 |
Correct |
56 ms |
2200 KB |
Output is correct |
29 |
Correct |
51 ms |
2240 KB |
Output is correct |
30 |
Correct |
26 ms |
1440 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |