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>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
signed main(){
int n,p,q;
cin>>n>>p>>q;
vector <int> a(n);
for(int i=0;i<n;i++)cin>>a[i];
sort(all(a));
int l=0,r=1e9;
while(l+1<r){
int md=(l+r)/2;
int pos=0;
int x=p,y=q;
while(pos<n){
auto cnt1=upper_bound(all(a),a[pos]+md-1)-a.begin();
auto cnt2=upper_bound(all(a),a[pos]+2*md-1)-a.begin();
if(cnt2-pos>cnt1-pos && y>0){
y--;
pos=cnt2;
}
else{
x--;
pos=cnt1;
}
}
if(x>=0 && y>=0)r=md;
else l=md;
}
cout<<r<<"\n";
}
/*
13 3 2
33
66
99
10
83
68
19
83
93
53
15
66
75
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |