#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
vector<long long> v;
long long findGap(int T, int n)
{
if(T==1){
long long s=-1;
long long t=(long long)1e18+1;
long long x=-1;
long long y=-1;
long long maxi=LLONG_MIN;
for(int i=1;i<=n/2;i++){
MinMax(s+1,t-1,&s,&t);
v.push_back(t);
v.push_back(s);
}
if(n%2==1){
MinMax(s+1,t-1,&s,&t);
v.push_back(s);
}
int i=1;
long long xx;
sort(v.begin(),v.end());
for(auto a:v){
if(i!=1){
maxi=max(maxi,a-xx);
}
i++;
xx=a;
}
return maxi;
}
long long s=-1;
long long t=(long long)1e18+1;
long long maxi=LLONG_MIN;
MinMax(s+1,t-1,&s,&t);
long long l=s;
long long r=t;
long long range=(t-s)/(n-1)+1;
long long x;
maxi=range-1;
for(long long i=1;i<n;i++){
MinMax(l+(i-1)*range,l+i*range-1,&s,&t);
if(t==-1)
continue;
if(i!=1){
maxi=max(maxi,s-x);
}
x=t;
}
return maxi;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:10:18: warning: unused variable 'x' [-Wunused-variable]
10 | long long x=-1;
| ^
gap.cpp:11:18: warning: unused variable 'y' [-Wunused-variable]
11 | long long y=-1;
| ^
gap.cpp:40:18: warning: unused variable 'r' [-Wunused-variable]
40 | long long r=t;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2552 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2384 KB |
Output is correct |
11 |
Correct |
1 ms |
2384 KB |
Output is correct |
12 |
Correct |
1 ms |
2384 KB |
Output is correct |
13 |
Correct |
1 ms |
2384 KB |
Output is correct |
14 |
Correct |
1 ms |
2384 KB |
Output is correct |
15 |
Correct |
1 ms |
2384 KB |
Output is correct |
16 |
Correct |
9 ms |
2896 KB |
Output is correct |
17 |
Correct |
10 ms |
2896 KB |
Output is correct |
18 |
Correct |
8 ms |
2896 KB |
Output is correct |
19 |
Correct |
9 ms |
2896 KB |
Output is correct |
20 |
Correct |
8 ms |
2896 KB |
Output is correct |
21 |
Correct |
33 ms |
4008 KB |
Output is correct |
22 |
Correct |
33 ms |
3796 KB |
Output is correct |
23 |
Correct |
35 ms |
3776 KB |
Output is correct |
24 |
Correct |
34 ms |
3784 KB |
Output is correct |
25 |
Correct |
31 ms |
3924 KB |
Output is correct |
26 |
Correct |
33 ms |
3784 KB |
Output is correct |
27 |
Correct |
31 ms |
3784 KB |
Output is correct |
28 |
Correct |
41 ms |
3776 KB |
Output is correct |
29 |
Correct |
34 ms |
4012 KB |
Output is correct |
30 |
Correct |
26 ms |
3784 KB |
Output is correct |
31 |
Correct |
1 ms |
2384 KB |
Output is correct |
32 |
Correct |
1 ms |
2384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
2 ms |
2384 KB |
Output is correct |
5 |
Correct |
2 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2560 KB |
Output is correct |
10 |
Correct |
1 ms |
2384 KB |
Output is correct |
11 |
Correct |
2 ms |
2384 KB |
Output is correct |
12 |
Correct |
2 ms |
2384 KB |
Output is correct |
13 |
Correct |
1 ms |
2384 KB |
Output is correct |
14 |
Correct |
2 ms |
2396 KB |
Output is correct |
15 |
Correct |
2 ms |
2384 KB |
Output is correct |
16 |
Correct |
10 ms |
2384 KB |
Output is correct |
17 |
Correct |
10 ms |
2384 KB |
Output is correct |
18 |
Correct |
11 ms |
2384 KB |
Output is correct |
19 |
Correct |
10 ms |
2384 KB |
Output is correct |
20 |
Correct |
6 ms |
2384 KB |
Output is correct |
21 |
Correct |
39 ms |
2860 KB |
Output is correct |
22 |
Correct |
39 ms |
2640 KB |
Output is correct |
23 |
Correct |
42 ms |
2640 KB |
Output is correct |
24 |
Correct |
43 ms |
2640 KB |
Output is correct |
25 |
Correct |
36 ms |
2640 KB |
Output is correct |
26 |
Correct |
37 ms |
2640 KB |
Output is correct |
27 |
Correct |
37 ms |
2640 KB |
Output is correct |
28 |
Correct |
40 ms |
2640 KB |
Output is correct |
29 |
Correct |
52 ms |
2640 KB |
Output is correct |
30 |
Correct |
23 ms |
2640 KB |
Output is correct |
31 |
Correct |
1 ms |
2384 KB |
Output is correct |
32 |
Correct |
1 ms |
2384 KB |
Output is correct |