#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
const ll INF=1e18;
ll findGap(int T,int N){
if(T==1){
vector<ll>v;
ll l=0;
ll r=INF;
for(int i=1;i<=(N+1)/2;i++){
ll a,b;
MinMax(l,r,&a,&b);
v.pb(a);
if(a!=b){
v.pb(b);
}
l=a+1;
r=b-1;
}
sort(all(v));
ll ans=v[1]-v[0];
for(int i=2;i<N;i++){
ans=max(ans,v[i]-v[i-1]);
}
return ans;
}
else{
ll l,r;
ll ans=0;
MinMax(0,INF,&l,&r);
ll dif=(r-l+N-2)/(N-1);
ll bef=l;
for(ll i=l;i<=r;i+=dif+1){
ll x,y;
MinMax(i,i+dif,&x,&y);
if(x==-1){
continue;
}
ans=max(ans,y-x);
ans=max(ans,x-bef);
bef=y;
}
return ans;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 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 |
1 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 |
12 ms |
812 KB |
Output is correct |
17 |
Correct |
11 ms |
848 KB |
Output is correct |
18 |
Correct |
11 ms |
848 KB |
Output is correct |
19 |
Correct |
10 ms |
928 KB |
Output is correct |
20 |
Correct |
8 ms |
876 KB |
Output is correct |
21 |
Correct |
40 ms |
2204 KB |
Output is correct |
22 |
Correct |
41 ms |
2236 KB |
Output is correct |
23 |
Correct |
41 ms |
2200 KB |
Output is correct |
24 |
Correct |
49 ms |
2232 KB |
Output is correct |
25 |
Correct |
39 ms |
2240 KB |
Output is correct |
26 |
Correct |
40 ms |
2144 KB |
Output is correct |
27 |
Correct |
43 ms |
2196 KB |
Output is correct |
28 |
Correct |
42 ms |
2220 KB |
Output is correct |
29 |
Correct |
42 ms |
2240 KB |
Output is correct |
30 |
Correct |
32 ms |
2200 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 |
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 |
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 |
208 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 |
220 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
15 ms |
512 KB |
Output is correct |
17 |
Correct |
13 ms |
512 KB |
Output is correct |
18 |
Correct |
12 ms |
428 KB |
Output is correct |
19 |
Correct |
13 ms |
516 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
57 ms |
1092 KB |
Output is correct |
22 |
Correct |
51 ms |
1084 KB |
Output is correct |
23 |
Correct |
52 ms |
1088 KB |
Output is correct |
24 |
Correct |
51 ms |
976 KB |
Output is correct |
25 |
Correct |
45 ms |
1132 KB |
Output is correct |
26 |
Correct |
50 ms |
1060 KB |
Output is correct |
27 |
Correct |
81 ms |
1084 KB |
Output is correct |
28 |
Correct |
52 ms |
1064 KB |
Output is correct |
29 |
Correct |
49 ms |
1076 KB |
Output is correct |
30 |
Correct |
30 ms |
1080 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |