#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
long long findGap(int q,int x){
if(q==2){
long long l=0,r=1e18;
MinMax(l,r,&l,&r);long long xd=l,lol=(r-l+x-2)/(x-1),ans=lol,c1,c2,i=l;
while(i+lol<r){
MinMax(i,i+lol,&c1,&c2);
if(c1!=-1)ans=max(ans,c1-xd),xd=c2;
i+=lol+1;
}
MinMax(i,r,&c1,&c2);
if(c1!=-1)ans=max(ans,c1-xd);
return ans;
}else{
vector<long long>a;
long long c=0,v=1e18,zz=x;
while(zz&&c<=v){
long long l,r;
MinMax(c,v,&l,&r);
if(l==-1)break;
a.push_back(l);if(l!=r)a.push_back(r);
c=l+1;v=r-1;zz-=2;
}
sort(a.begin(),a.end());
long long ret=0;
for(int i=0;i<(int)a.size()-1;i++)ret=max(ret,a[i+1]-a[i]);
return ret;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
1 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 |
848 KB |
Output is correct |
17 |
Correct |
12 ms |
848 KB |
Output is correct |
18 |
Correct |
10 ms |
848 KB |
Output is correct |
19 |
Correct |
10 ms |
848 KB |
Output is correct |
20 |
Correct |
9 ms |
848 KB |
Output is correct |
21 |
Correct |
44 ms |
2152 KB |
Output is correct |
22 |
Correct |
42 ms |
2168 KB |
Output is correct |
23 |
Correct |
44 ms |
2184 KB |
Output is correct |
24 |
Correct |
42 ms |
2144 KB |
Output is correct |
25 |
Correct |
38 ms |
2256 KB |
Output is correct |
26 |
Correct |
44 ms |
2244 KB |
Output is correct |
27 |
Correct |
50 ms |
2172 KB |
Output is correct |
28 |
Correct |
44 ms |
2200 KB |
Output is correct |
29 |
Correct |
41 ms |
2224 KB |
Output is correct |
30 |
Correct |
35 ms |
2224 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 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 |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
15 ms |
464 KB |
Output is correct |
17 |
Correct |
13 ms |
464 KB |
Output is correct |
18 |
Correct |
14 ms |
424 KB |
Output is correct |
19 |
Correct |
17 ms |
512 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
55 ms |
1000 KB |
Output is correct |
22 |
Correct |
52 ms |
1068 KB |
Output is correct |
23 |
Correct |
51 ms |
1020 KB |
Output is correct |
24 |
Correct |
54 ms |
972 KB |
Output is correct |
25 |
Correct |
58 ms |
1084 KB |
Output is correct |
26 |
Correct |
54 ms |
1012 KB |
Output is correct |
27 |
Correct |
62 ms |
1004 KB |
Output is correct |
28 |
Correct |
57 ms |
1060 KB |
Output is correct |
29 |
Correct |
56 ms |
1036 KB |
Output is correct |
30 |
Correct |
28 ms |
1108 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |