이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |