//~ #pragma GCC optimize("O3,unroll-loops")
//~ #pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
const int inf = INT_MAX;
const int mod = 1e9+7;
int n, P, Q, w;
int a[2005], dp[2005][2005];
int f(int ind, int p){
if(ind > n) return 0;
if(dp[ind][p] != -1) return dp[ind][p];
//kucuk
int t1 = inf, t2 = inf;
if(p){
int ind2 = upper_bound(a+1, a+n+1, a[ind]+w-1) - a;
//~ cout<<ind<<" .. "<<ind2<<" .. " << w<<endl;
//~ if(a[ind] + w - 1 >= a[n])return true;
t1 = f(ind2, p-1);
}
int ind2 = upper_bound(a+1, a+n+1, a[ind]+w*2-1) - a;
//~ if(a[ind] + w*2 - 1 >= a[n])return true;
t2 = f(ind2, p)+1;
return dp[ind][p] = min(t1, t2);
}
bool check(int x){
w = x;
memset(dp, -1, sizeof(dp));
if(f(1, P)<=Q){
return true;
}
else return false;
}
int32_t main(){
fast;
cin>>n>>P>>Q;
for(int i=1;i<=n;i++){
cin>>a[i];
}
sort(a+1, a+n+1);
if(P + Q >= n){
cout<<1<<endl;
return 0;
}
int l = 1, r = 1e9;
while(l<=r){
int m = (l+r)/2;
if(check(m)){
r = m-1;
}
else l = m+1;
}
cout<<l<<endl;
}
//https://usaco.org/current/current/index.php?page=viewproblem2&cpid=282 bunu coz
//~ 10 15 19 33 53 66 66 68 75 83 83 93 99
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |