#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];
vector<ll> v,len;
ll findGap(int T,int N){
if(T==1){
int l=0,r=N-1;ll cl=0,cr=1e18,mn,mx;
while(l<=r){
MinMax(cl,cr,&mn,&mx);
a[l]=mn,a[r]=mx,cl=mn+1,cr=mx-1,++l,--r;
}
ll ans=0;
for(int i=1;i<N;++i)ans=max(ans,a[i]-a[i-1]);
return ans;
}
else{
ll mn,mx,x,y;
MinMax(0,1e18,&mn,&mx);
x=mn+1,y=mx-1;
ll l=(y-x+1)/(N-1);
for(int i=0;i<N-1;++i)len.push_back(l);
for(int i=0;i<(y-x+1)-l*(N-1);++i)++len[i];
v.push_back(x-1);
int ptr=0;ll cur=x;
while(cur<y){
MinMax(cur,cur+len[ptr]-1,&mn,&mx);
if(mn!=-1)v.push_back(mn);
if(mx!=-1)v.push_back(mx);
cur+=len[ptr];++ptr;
}
v.push_back(y+1);
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 'll findGap(int, int)':
gap.cpp:41:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i=1;i<v.size();++i)ans=max(ans,v[i]-v[i-1]);
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 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 |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
344 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 |
10 ms |
628 KB |
Output is correct |
17 |
Correct |
9 ms |
664 KB |
Output is correct |
18 |
Correct |
11 ms |
584 KB |
Output is correct |
19 |
Correct |
10 ms |
692 KB |
Output is correct |
20 |
Correct |
7 ms |
584 KB |
Output is correct |
21 |
Correct |
37 ms |
1808 KB |
Output is correct |
22 |
Correct |
35 ms |
1752 KB |
Output is correct |
23 |
Correct |
37 ms |
1812 KB |
Output is correct |
24 |
Correct |
36 ms |
1796 KB |
Output is correct |
25 |
Correct |
37 ms |
1756 KB |
Output is correct |
26 |
Correct |
42 ms |
1824 KB |
Output is correct |
27 |
Correct |
36 ms |
1856 KB |
Output is correct |
28 |
Correct |
36 ms |
1856 KB |
Output is correct |
29 |
Correct |
42 ms |
1772 KB |
Output is correct |
30 |
Correct |
28 ms |
1756 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 |
1 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 |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
328 KB |
Output is correct |
9 |
Correct |
0 ms |
328 KB |
Output is correct |
10 |
Correct |
0 ms |
328 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 |
12 ms |
1112 KB |
Output is correct |
17 |
Correct |
12 ms |
1104 KB |
Output is correct |
18 |
Correct |
12 ms |
1096 KB |
Output is correct |
19 |
Correct |
13 ms |
1088 KB |
Output is correct |
20 |
Correct |
7 ms |
840 KB |
Output is correct |
21 |
Correct |
53 ms |
3352 KB |
Output is correct |
22 |
Correct |
52 ms |
3344 KB |
Output is correct |
23 |
Correct |
53 ms |
3360 KB |
Output is correct |
24 |
Correct |
63 ms |
3344 KB |
Output is correct |
25 |
Correct |
48 ms |
3984 KB |
Output is correct |
26 |
Correct |
52 ms |
3336 KB |
Output is correct |
27 |
Correct |
54 ms |
3344 KB |
Output is correct |
28 |
Correct |
52 ms |
3348 KB |
Output is correct |
29 |
Correct |
57 ms |
3400 KB |
Output is correct |
30 |
Correct |
29 ms |
2280 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |