#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define v(a) vector<a>
v(ll) arr;
ll n, p, q;
ll binsearch(ll l, ll r, ll c1){
if(l <= r){
ll mid = (l+r)/2;
ll cur = 2*mid*c1;
bool ok = false;
ll pos = upper_bound(arr.begin(), arr.end(), cur)-arr.begin()-1;
// cout << pos << " " << mid << '\n';
if(n-pos-1 <= p) ok = true;
if(ok) return min(mid, binsearch(l, mid-1, c1));
return binsearch(mid+1, r, c1);
} return 1e9;
}
int main(){
cin >> n >> p >> q;
arr.resize(n);
for(int i = 0; i < n; i++) cin >> arr[i];
sort(arr.begin(), arr.end());
if(p >= n || q >= n) cout << 1;
else {
cout << binsearch(1, 1e9, q);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |