#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n,p,q,a[2005];
int nxt[2005], nxt2[2005];
char dp[105][105][105];
bool f(int x, int y, int z){
if(y == -1 || z == -1) return 0;
if(x == n) return 1;
if(~dp[x][y][z]) return dp[x][y][z];
return dp[x][y][z] = f(nxt[x],y-1,z) || f(nxt2[x],y,z-1);
}
bool trial(int x){
for (int i=0; i<n; i++) {
nxt[i] = (int)(lower_bound(a,a+n,a[i]+x) - a);
nxt2[i] = (int)(lower_bound(a,a+n,a[i]+2*x) - a);
}
memset(dp,-1,sizeof(dp));
return f(0,p,q);
}
int main(){
scanf("%d %d %d",&n,&p,&q);
for (int i=0; i<n; i++) {
scanf("%d",&a[i]);
}
p = min(p,n);
q = min(q,n);
sort(a,a+n);
int s = 0, e = 5e8;
while (s != e) {
int m = (s+e)/2;
if(trial(m)) e = m;
else s = m+1;
}
printf("%d",s);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2240 KB |
Output is correct |
2 |
Correct |
3 ms |
2240 KB |
Output is correct |
3 |
Correct |
3 ms |
2240 KB |
Output is correct |
4 |
Correct |
3 ms |
2240 KB |
Output is correct |
5 |
Correct |
3 ms |
2240 KB |
Output is correct |
6 |
Correct |
3 ms |
2240 KB |
Output is correct |
7 |
Correct |
3 ms |
2240 KB |
Output is correct |
8 |
Correct |
3 ms |
2240 KB |
Output is correct |
9 |
Correct |
3 ms |
2240 KB |
Output is correct |
10 |
Correct |
4 ms |
2240 KB |
Output is correct |
11 |
Correct |
4 ms |
2240 KB |
Output is correct |
12 |
Correct |
3 ms |
2240 KB |
Output is correct |
13 |
Correct |
3 ms |
2240 KB |
Output is correct |
14 |
Correct |
3 ms |
2240 KB |
Output is correct |
15 |
Correct |
3 ms |
2240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
2236 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |