| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 77751 | nxteru | 구경하기 (JOI13_watching) | C++14 | 690 ms | 16592 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int n,p,q,a[2005],dp[2005][2005];
bool solve(int w){
if(p+q>=n)return true;
for(int i=0;i<=n;i++){
for(int j=0;j<=p;j++){
dp[i][j]=-1;
}
}
dp[0][p]=q;
for(int i=0;i<n;i++){
for(int j=0;j<=p;j++){
if(dp[i][j]>=0){
if(dp[i][j]>0){
int k=upper_bound(a,a+n,a[i]+w*2-1)-a;
dp[k][j]=max(dp[k][j],dp[i][j]-1);
}
if(j>0){
int k=upper_bound(a,a+n,a[i]+w-1)-a;
dp[k][j-1]=max(dp[k][j-1],dp[i][j]);
}
}
}
}
for(int i=0;i<=p;i++){
if(dp[n][i]>=0)return true;
}
return false;
}
int main(void){
scanf("%d%d%d",&n,&p,&q);
for(int i=0;i<n;i++)scanf("%d",a+i);
sort(a,a+n);
int r=0,l=1000000000;
while(l-r>1){
int m=(r+l)/2;
if(solve(m))l=m;
else r=m;
}
printf("%d\n",l);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
