# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
438789 | MilosMilutinovic | Watching (JOI13_watching) | C++14 | 286 ms | 16840 KiB |
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;
const int N=2050;
int n,p,q,a[N],dp[N][N];
bool Check(int w){
memset(dp,1e9,sizeof dp);
dp[0][0]=0;
int x=0,y=0;
for(int i=1;i<=n;i++){
while(a[i]-a[x+1]>=w)x++;
while(a[i]-a[y+1]>=2*w)y++;
for(int j=0;j<=n;j++){
dp[i][j]=dp[x][j]+1;
if(j>0)dp[i][j]=min(dp[i][j],dp[y][j-1]);
}
}
for(int j=0;j<=min(n,q);j++){
if(dp[n][j]<=p)return true;
}
return false;
}
int main(){
scanf("%i %i %i",&n,&p,&q);
for(int i=1;i<=n;i++)scanf("%i",&a[i]);
sort(a+1,a+n+1);
int bot=1,top=1e9,ans=1e9;
while(bot<=top){
int mid=bot+top>>1;
if(Check(mid))ans=mid,top=mid-1;
else bot=mid+1;
}
printf("%i",ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |