#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
long long findGap(int t, int n)
{
long long lx,rx,l=0,r=1e18,ans=0,bl;
if(t==1){
MinMax(l,r,&lx,&rx);l=lx;r=rx;
for(int i=2;i<=(n+1)/2;i++){
MinMax(l+1,r-1,&lx,&rx);
ans=max(ans,max(lx-l,r-rx));l=lx;r=rx;
}
ans=max(ans,r-l);
}
else{
MinMax(l,r,&lx,&rx);ans=bl=(rx-lx-1)/(n-1)+1;
long long pre=lx,lst=lx+1;l=lx;r=rx;
while(lst+bl<=r){
MinMax(lst,lst+bl-1,&lx,&rx);
ans=max(ans,lx-pre);
if(rx!=-1) pre=rx;
lst=lst+bl;
}
if(lst<=(r-1)){
MinMax(lst,r-1,&lx,&rx);
ans=max(ans,lx-pre);
if(rx!=-1) pre=rx;
}
ans=max(ans,r-pre);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
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 |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
9 ms |
464 KB |
Output is correct |
17 |
Correct |
9 ms |
432 KB |
Output is correct |
18 |
Correct |
11 ms |
504 KB |
Output is correct |
19 |
Correct |
10 ms |
592 KB |
Output is correct |
20 |
Correct |
8 ms |
464 KB |
Output is correct |
21 |
Correct |
36 ms |
1084 KB |
Output is correct |
22 |
Correct |
43 ms |
992 KB |
Output is correct |
23 |
Correct |
37 ms |
1084 KB |
Output is correct |
24 |
Correct |
38 ms |
1084 KB |
Output is correct |
25 |
Correct |
32 ms |
1088 KB |
Output is correct |
26 |
Correct |
38 ms |
1080 KB |
Output is correct |
27 |
Correct |
36 ms |
1060 KB |
Output is correct |
28 |
Correct |
40 ms |
1088 KB |
Output is correct |
29 |
Correct |
37 ms |
1048 KB |
Output is correct |
30 |
Correct |
35 ms |
992 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 |
1 ms |
256 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 |
208 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 |
516 KB |
Output is correct |
17 |
Correct |
13 ms |
464 KB |
Output is correct |
18 |
Correct |
14 ms |
464 KB |
Output is correct |
19 |
Correct |
12 ms |
520 KB |
Output is correct |
20 |
Correct |
7 ms |
464 KB |
Output is correct |
21 |
Correct |
53 ms |
1060 KB |
Output is correct |
22 |
Correct |
58 ms |
1000 KB |
Output is correct |
23 |
Correct |
50 ms |
972 KB |
Output is correct |
24 |
Correct |
61 ms |
1056 KB |
Output is correct |
25 |
Correct |
57 ms |
1060 KB |
Output is correct |
26 |
Correct |
53 ms |
1044 KB |
Output is correct |
27 |
Correct |
53 ms |
1080 KB |
Output is correct |
28 |
Correct |
50 ms |
1036 KB |
Output is correct |
29 |
Correct |
59 ms |
1056 KB |
Output is correct |
30 |
Correct |
29 ms |
1008 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |