#include "gap.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
#define ll long long
ll a[200005],inf=1e18;
ll mx,mn;
long long findGap(int T, int N){
if(T==1){
ll l=0,r=N,x=0,y=inf;
while(l<r){
MinMax(x,y,&mn,&mx);
a[l++]=mn,a[--r]=mx;
x=mn+1;
y=mx-1;
}
ll ans=0;
for(int i=0;i<N-1;i++)
ans=max(ans,a[i+1]-a[i]);
return ans;
}
else{
MinMax(1,1e18,&mn,&mx);
if(N==2)
return mx-mn;
ll sz=(mx-mn-1);
ll s=mn+1,last=mn,ans=0;
for(int i=0;i<N-1;i++){
ll tmp=s+sz/(N-1)-1;
if(i<sz%(N-1)) tmp++;
MinMax(s,tmp,&mn,&mx);
if(mn!=-1){
ans=max(ans,mn-last);
last=mx;
}
s=tmp+1;
}
return max(ans,s-last);
}
//return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
336 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
336 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 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 |
692 KB |
Output is correct |
17 |
Correct |
10 ms |
688 KB |
Output is correct |
18 |
Correct |
10 ms |
608 KB |
Output is correct |
19 |
Correct |
11 ms |
592 KB |
Output is correct |
20 |
Correct |
7 ms |
720 KB |
Output is correct |
21 |
Correct |
36 ms |
1864 KB |
Output is correct |
22 |
Correct |
36 ms |
1800 KB |
Output is correct |
23 |
Correct |
43 ms |
1828 KB |
Output is correct |
24 |
Correct |
46 ms |
1756 KB |
Output is correct |
25 |
Correct |
38 ms |
1752 KB |
Output is correct |
26 |
Correct |
44 ms |
1760 KB |
Output is correct |
27 |
Correct |
38 ms |
1960 KB |
Output is correct |
28 |
Correct |
35 ms |
1812 KB |
Output is correct |
29 |
Correct |
36 ms |
1736 KB |
Output is correct |
30 |
Correct |
31 ms |
1776 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
264 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 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 |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
260 KB |
Output is correct |
11 |
Correct |
1 ms |
208 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 |
208 KB |
Output is correct |
16 |
Correct |
13 ms |
472 KB |
Output is correct |
17 |
Correct |
12 ms |
464 KB |
Output is correct |
18 |
Correct |
13 ms |
524 KB |
Output is correct |
19 |
Correct |
13 ms |
484 KB |
Output is correct |
20 |
Correct |
7 ms |
464 KB |
Output is correct |
21 |
Correct |
53 ms |
1088 KB |
Output is correct |
22 |
Correct |
56 ms |
1056 KB |
Output is correct |
23 |
Correct |
48 ms |
1060 KB |
Output is correct |
24 |
Correct |
53 ms |
1020 KB |
Output is correct |
25 |
Correct |
50 ms |
1064 KB |
Output is correct |
26 |
Correct |
51 ms |
1096 KB |
Output is correct |
27 |
Correct |
49 ms |
1016 KB |
Output is correct |
28 |
Correct |
56 ms |
1092 KB |
Output is correct |
29 |
Correct |
56 ms |
1088 KB |
Output is correct |
30 |
Correct |
27 ms |
976 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |