#include<bits/stdc++.h>
#include "gap.h"
//#include "grader.cpp"
using namespace std;
typedef long long ll;
const ll inf =1e18;
const ll mod=998244353;
ll findGap(int T, int N){
if(T==1){
int f=1;int en=N;
ll mn=0;ll mx=1e18;ll a[N+5];
ll s=0;ll t=1e18;
while(mn<=mx){
//if(f>=en){break;}
if(f>en){break;}
MinMax( s, t, &mn, &mx);
a[f]=mn;
a[en]=mx;
s=mn+1;
t=mx-1;
f++;en--;
}
ll ans=1;
for(int i=1;i<N;i++){
ans=max(ans,a[i+1]-a[i]);
}
return ans;
}
ll mn=0; ll mx=1e18;
MinMax( 0, mx, &mn, &mx);
ll st=mn;ll en=mx;
ll len=(mx-(mn+2)+N)/(N-1);
ll last=mn;
vector<ll>v;
v.push_back(mn);
//cout<<len<<endl;
//cout<<mx<<endl;
//cout<<en<<endl;
ll i=mn+1;
for(;i<=en;i+=len){
MinMax( i, min(i+len-1,en-1), &mn, &mx);
// cout<<i<<" "<<min(i+len-1,en-1)<<" "<<en<<endl;
if(mn!=-1){
v.push_back(mn); v.push_back(mx);
last=mx;
}
// cout<<"test \n";
}
// cout<<i<<" "<<mx<<endl;
MinMax( last, en-1, &mn, &mx);
v.push_back(mx);
v.push_back(mn);
v.push_back(en);
ll ans=len;
sort(v.begin(),v.end());
for( int j=1;j<v.size();j++){
ans=max(ans,v[j]-v[j-1]);
}
//cout<<ans<<endl;
return ans;
}
Compilation message
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:65:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for( int j=1;j<v.size();j++){
| ~^~~~~~~~~
gap.cpp:34:4: warning: unused variable 'st' [-Wunused-variable]
34 | ll st=mn;ll en=mx;
| ^~
# |
결과 |
실행 시간 |
메모리 |
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 |
0 ms |
208 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 |
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 |
704 KB |
Output is correct |
17 |
Correct |
9 ms |
620 KB |
Output is correct |
18 |
Correct |
9 ms |
592 KB |
Output is correct |
19 |
Correct |
9 ms |
704 KB |
Output is correct |
20 |
Correct |
8 ms |
592 KB |
Output is correct |
21 |
Correct |
36 ms |
1816 KB |
Output is correct |
22 |
Correct |
34 ms |
1864 KB |
Output is correct |
23 |
Correct |
37 ms |
1852 KB |
Output is correct |
24 |
Correct |
36 ms |
1864 KB |
Output is correct |
25 |
Correct |
36 ms |
1836 KB |
Output is correct |
26 |
Correct |
35 ms |
1832 KB |
Output is correct |
27 |
Correct |
34 ms |
1780 KB |
Output is correct |
28 |
Correct |
35 ms |
1768 KB |
Output is correct |
29 |
Correct |
35 ms |
2000 KB |
Output is correct |
30 |
Correct |
29 ms |
1852 KB |
Output is correct |
31 |
Correct |
0 ms |
208 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 |
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 |
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 |
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 |
13 ms |
848 KB |
Output is correct |
17 |
Correct |
13 ms |
836 KB |
Output is correct |
18 |
Correct |
13 ms |
876 KB |
Output is correct |
19 |
Correct |
13 ms |
812 KB |
Output is correct |
20 |
Correct |
8 ms |
524 KB |
Output is correct |
21 |
Correct |
51 ms |
2240 KB |
Output is correct |
22 |
Correct |
53 ms |
2164 KB |
Output is correct |
23 |
Correct |
54 ms |
2332 KB |
Output is correct |
24 |
Correct |
51 ms |
2136 KB |
Output is correct |
25 |
Correct |
49 ms |
3224 KB |
Output is correct |
26 |
Correct |
53 ms |
2144 KB |
Output is correct |
27 |
Correct |
61 ms |
2204 KB |
Output is correct |
28 |
Correct |
52 ms |
2212 KB |
Output is correct |
29 |
Correct |
51 ms |
2208 KB |
Output is correct |
30 |
Correct |
26 ms |
1480 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |