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;
using ll = long long ;
ll a[2004];
ll n;
bool Can(ll x, ll s, ll small, ll large) {
ll p;
if ( s < 1) return 1;
if ( small > 0) {
p = lower_bound(a + 1, a + n + 1, a[s] - x + 1) - a;
p --;
if (Can(x, p, small- 1, large)) return 1;
}
if ( large > 0) {
p = lower_bound(a + 1, a + n + 1, a[s] - (2 * x) + 1) - a;
p --;
if (Can(x, p, small, large - 1)) return 1;
}
return 0;
}
int main() {
// freopen("moocast.in", "r", stdin);
// freopen("moocast.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(NULL);
ll i, lo, hi, mid, small, large;
cin >> n >> small >> large;
if ( small + large >= n) {
cout << 1 << endl;
return 0;
}
for (i = 1; i <= n; i ++) {
cin >> a[i];
}
sort ( a + 1, a + n + 1);
lo = 1;
hi = 1e9;
while ( lo < hi) {
mid = (lo + hi)/2;
if ( !Can(mid, n, small, large)) lo = mid + 1;
else hi = mid;
}
cout << lo << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |