#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,p,q;
int dp[2005][2005];
int inf=1e9;
vector<int>v;
bool check(int x){
//cerr<<x<<"\n";
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)dp[i][j]=inf;
for(int i=1;i<=n;i++){
for(int j=0;j<=p;j++){
int id=upper_bound(v.begin(),v.end(),v[i-1]-2*x)-v.begin();
dp[i][j]=dp[id][j]+1;
id=upper_bound(v.begin(),v.end(),v[i-1]-x)-v.begin();
if(j!=0)dp[i][j]=min(dp[i][j],dp[id][j-1]);
}
}
if(dp[n][p]<=q)return true;
return false;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>p>>q;
for(int i=1;i<=n;i++){
int x;cin>>x;
v.push_back(x);
}
sort(v.begin(),v.end());
if(p+q>=n){
cout<<1;
return 0;
}
long long st=1,en=1e9;
int ans=0;
while(st<=en){
long long m=(st+en)/2;
if(check(m)){
ans=m;
en=m-1;
}else{
st=m+1;
}
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |