This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |