# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
77440 | Vardanyan | 구경하기 (JOI13_watching) | C++14 | 880 ms | 36216 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int a[N];
int mxshort[N];
int mxlong[N];
int dp[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;
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;
dp[0][0] = 1;
int u = 5;
for(int i = 0;i<=min(n,p);i++){
for(int j = 0;j<=min(n,q);j++){
int pos = max(1,dp[i][j]);
dp[i+1][j] = max(dp[i+1][j],mxshort[pos]+1);
dp[i][j+1] = max(dp[i][j+1],mxlong[pos]+1);
}
}
for(int i = 0;i<=min(n,p);i++){
for(int j = 0;j<=min(n,q);j++) if(dp[i][j]>n) f = true;
}
if(f){
ans = m;
r = m-1;
}
else l = m+1;
}
cout<<ans<<endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |