| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 35031 | dqhungdl | 구경하기 (JOI13_watching) | C++14 | 519 ms | 17724 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n,P,Q,a[2005],f[2005][2005];
bool Check(int w)
{
for(int i=0;i<=n;i++)
for(int j=0;j<=P;j++)
f[i][j]=1e9;
f[0][0]=0;
for(int i=1;i<=n;i++)
{
int id1,id2;
for(int j=1;j<=i;j++)
if(a[i]-a[j]+1<=w)
{
id1=j;
break;
}
for(int j=1;j<=i;j++)
if(a[i]-a[j]+1<=2*w)
{
id2=j;
break;
}
for(int j=1;j<=P;j++)
f[i][j]=min(f[i][j],f[id1-1][j-1]);
for(int j=0;j<=P;j++)
f[i][j]=min(f[i][j],f[id2-1][j]+1);
}
for(int j=0;j<=P;j++)
if(f[n][j]<=Q)
return true;
return false;
}
int main()
{
cin>>n>>P>>Q;
P=min(P,n);
Q=min(Q,n);
for(int i=1;i<=n;i++)
cin>>a[i];
sort(a+1,a+n+1);
int res,l=1,r=1e9;
while(l<=r)
{
int mid=(l+r)/2;
if(Check(mid)==true)
{
res=mid;
r=mid-1;
}
else
l=mid+1;
}
cout<<res;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
