| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 563386 | hibiki | Watching (JOI13_watching) | C++11 | 268 ms | 16016 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
int n,p,q,dp[2005][2005];
vector<int> v;
int main()
{
scanf("%d %d %d",&n,&p,&q);
int lst = -1;
for(int i = 0; i < n; i++)
{
int a;
scanf("%d",&a);
v.pb(a);
}
if(p + q >= n)
{
printf("1\n");
return 0;
}
sort(v.begin(),v.end());
int l = 1, r = 1e9 + 5;
while(l <= r)
{
int mid = (l + r) / 2;
if(l == r)
{
printf("%d\n",l);
return 0;
}
for(int i = 0; i < n; i++)
for(int j = 0; j <= p; j++)
dp[i][j] = 1e9;
for(int i = 0; i < n; i++)
{
int po = v[i];
// use p
int p_po = upper_bound(v.begin(),v.end(),po - mid) - v.begin() - 1;
if(p_po == -1)
dp[i][1] = 0;
else
for(int j = 1; j <= p; j++)
{
dp[i][j] = min(dp[i][j],dp[p_po][j - 1]);
}
// use q
p_po = upper_bound(v.begin(),v.end(),po - mid * 2) - v.begin() - 1;
if(p_po == -1)
dp[i][0] = 1;
else
for(int j = 0; j <= p; j++)
{
dp[i][j] = min(dp[i][j],dp[p_po][j] + 1);
}
}
bool chk = false;
for(int i = 0; i <= p; i++)
if(dp[n - 1][i] <= q)
{
chk = true;
break;
}
if(chk)
r = mid;
else
l = mid + 1;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
