#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ff first
#define ss second
using namespace std;
int n,m,k,i,j,a[30001],b[30001],x,y,l,r,d[3001][3001],t[30001];
bool check(int o){
for(int k=0; k<=n; ++k){
a[k]=lower_bound(t+k+1,t+n+1,t[k+1]+o)-t-1;
b[k]=lower_bound(t+k+1,t+n+1,t[k+1]+(o<<1))-t-1;
}
for(int i=0; i<=x; i++){
for(int j=0; j<=y; j++){
if(i*j!=0){
d[i][j]=max(a[d[i-1][j]],b[d[i][j-1]]);
}
else{
if(i!=0){
d[i][j]=a[d[i-1][j]];
}
else if(j!=0) d[i][j]=b[d[i][j-1]];
}
}
}
if(n==d[x][y])return true;
else return false;
}
signed main() {
cin>>n>>x>>y;
if(x+y>=n){cout<<1; return 0; }
for(k=1; k<=n; k++)cin>>t[k];
sort(t+1,t+n+1);
t[n+1]=1e9;
l=1; r=1e9;
int ans=1e9;
while(l<=r){
int md=(l+r)/2;
if(check(md)){ans=md; r=md-1;}
else l=md+1;
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
1 ms |
444 KB |
Output is correct |
13 |
Correct |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
600 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
460 KB |
Output is correct |
8 |
Correct |
11 ms |
3420 KB |
Output is correct |
9 |
Correct |
11 ms |
17340 KB |
Output is correct |
10 |
Correct |
17 ms |
44012 KB |
Output is correct |
11 |
Correct |
15 ms |
4180 KB |
Output is correct |
12 |
Correct |
72 ms |
23900 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |