#include<bits/stdc++.h>
using namespace std;
const int N=2e3+10;
int dp[N][N],arr[N];
int main(){
int n,p,q;
cin>>n >>p >>q;
for(int i=1;i<=n;i++) cin>>arr[i];
arr[n+1]=INT_MAX;
sort(arr+1,arr+n+1);
int l=0,r=1e9;
while(l<r){
int w=(l+r)/2;
for(int i=0;i<=p;i++) for(int j=0;j<=q;j++) dp[i][j]=0;
for(int i=0;i<=p;i++){
for(int j=0;j<=q;j++){
if(i) dp[i][j]=max(dp[i][j],dp[i-1][j]);
if(j) dp[i][j]=max(dp[i][j],dp[i][j-1]);
if(dp[i][j]==n) continue;
if(i) dp[i][j]=max(dp[i][j],dp[i-1][j]+(int)(upper_bound(arr+dp[i-1][j]+1,arr+n+2,w+arr[dp[i-1][j]+1]-1)-(arr+dp[i-1][j]+1)));
if(j) dp[i][j]=max(dp[i][j],dp[i][j-1]+(int)(upper_bound(arr+dp[i][j-1]+1,arr+n+2,2*w+arr[dp[i][j-1]+1]-1)-(arr+dp[i][j-1]+1)));
}
}
if(dp[p][q]==n) r=w;
else l=w+1;
/*cout<<w <<"\n";
for(int i=0;i<=p;i++){
for(int j=0;j<=q;j++){
cout<<dp[i][j] <<" ";
}
cout<<"\n";
}*/
}
cout<<l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Runtime error |
26 ms |
31056 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
471 ms |
12944 KB |
Output is correct |
4 |
Runtime error |
24 ms |
31324 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |