#include <bits/stdc++.h>
using namespace std;
long long n, p, q;
long long a[2005];
bool visited[2005];
bool check(long long w){
long long smallCam = p;
long long bigCam = q;
for(long long i = 0; i < n; ++i){
long long ind1 = upper_bound(a, a + n, a[i] + w - 1) - a;
long long ind2 = upper_bound(a, a + n, a[i] + 2 * w - 1) - a;
if(ind2 > ind1){
if(bigCam){
bigCam--;
i = ind2 - 1;
continue;
}
}
if(smallCam){
smallCam--;
i = ind1 - 1;
}else if(bigCam){
bigCam--;
i = ind2 - 1;
}else{
return false;
}
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> p >> q;
for(long long i = 0; i < n; ++i){
cin >> a[i];
}
sort(a, a + n);
long long l = 1;
long long r = 100000000;
long long lc = -1;
while(l <= r){
long long mid = (l + r) / 2;
bool ch = check(mid);
if(ch){
r = mid - 1;
lc = mid;
}else{
l = mid + 1;
}
}
cout << lc << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |