#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 |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
436 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |