# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
77434 | Vardanyan | 구경하기 (JOI13_watching) | C++14 | 176 ms | 64128 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 = 201;
int a[N];
int mxshort[N];
int mxlong[N];
int dp[N][N][N];
int main(){
int n,p,q;
scanf("%d%d%d",&n,&p,&q);
for(int i = 1;i<=n;i++) scanf("%d",&a[i]);
sort(a+1,a+1+n);
int l = 1;
int r = 1000*1000*1000;
int ans = r;
while(l<=r){
int m = (l+r)/2;
/*if(m == 1){
cout<<0<<endl;
}*/
memset(mxlong,0,sizeof(mxlong));
memset(mxshort,0,sizeof(mxshort));
memset(dp,0,sizeof(dp));
int now = n;
int noww = n;
for(int i = n;i>=1;i--){
while(!(abs(a[i]-a[now])+1<=m)) now--;
mxshort[i] = now;
while(!(abs(a[i]-a[noww])+1<=2*m)) noww--;
mxlong[i] = noww;
}
bool f = false;
for(int i = 1;i<=n;i++){
for(int j = 0;j<=min(100,p);j++){
for(int k = 0;k<=min(100,q);k++){
if(i == 1 || dp[i][j][k]){
if(i == n && (j<p || k<q)){
f = true;
break;
}
dp[min(n,mxshort[i]+1)][j+1][k] = dp[min(n,mxlong[i]+1)][j][k+1] = 1;
}
}
if(f) break;
}
if(f) break;
}
if(f){
ans = m;
r = m-1;
}
else l = m+1;
}
cout<<ans-1<<endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |