| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 228360 | Nayna | 구경하기 (JOI13_watching) | C++14 | 1085 ms | 31744 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int mxn = 2e3+5;
typedef long long ll;
const ll inf = 1e16;
ll arr[mxn];
ll dp[mxn][mxn];
ll n, P, Q;
bool solve(ll w)
{
    for(int i = 0; i <= n; i++)
        for(int r = 0; r <= n; r++) dp[i][r] = inf;
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int r = 0; r <= P; r++)
        {
            int x = upper_bound(arr+1, arr+n+1, arr[i]-w)-arr-1;
            int y = upper_bound(arr+1, arr+n+1, arr[i]-w-w)-arr-1;
            if(r) dp[i][r] = min(dp[i][r], dp[x][r-1]);
            dp[i][r] = min(dp[i][r], dp[y][r]+1);
        }
    }
    for(int i = 0; i <= n; i++)
        if(dp[n][i]<=Q) return true;
    return false;
}
int main()
{
    scanf("%lld%lld%lld", &n, &P, &Q);
    P = min(n, P);
    Q = min(n, Q);
    for(int i = 1; i <= n; i++) scanf("%lld", &arr[i]);
    sort(arr+1, arr+n+1);
    ll lo = 1, hi = 1e9+5, ans = inf;
    while(lo<=hi)
    {
        ll mid = (lo+hi)>>1;
        if(solve(mid))
        {
            hi = mid-1;
            ans = min(ans, mid);
        }
        else lo = mid+1;
    }
    printf("%lld\n", ans);
    return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
