| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 559077 | groshi | 구경하기 (JOI13_watching) | C++17 | 7 ms | 8660 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,p,q;
vector<int> Q;
int dp[1020][1020];
bool check(int ile)
{
for(int i=0;i<=n;i++)
for(int j=0;j<=min(n,p);j++)
dp[i][j]=1000000000;
dp[0][0]=0;
for(int i=1;i<=Q.size();i++)
{
int gdzie1=lower_bound(Q.begin(),Q.end(),Q[i-1]-2*ile+1)-Q.begin();
int gdzie2=lower_bound(Q.begin(),Q.end(),Q[i-1]-ile+1)-Q.begin();
for(int j=0;j<=min(n,p);j++)
{
if(j>0)
dp[i][j]=min(dp[gdzie1][j]+1,dp[gdzie2][j-1]);
else dp[i][j]=dp[gdzie1][j]+1;
}
}
for(int i=0;i<=min(n,p);i++)
if(dp[n][i]<=q)
return 1;
return 0;
}
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
cin>>n>>p>>q;
int x;
for(int i=1;i<=n;i++)
{
cin>>x;
Q.push_back(x);
}
sort(Q.begin(),Q.end());
int pocz=0,kon=1000000005,sre,ostd;
while(pocz<kon)
{
sre=(pocz+kon)/2;
if(check(sre))
{
ostd=sre;
kon=sre;
}
else pocz=sre+1;
}
cout<<ostd;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
