結果

問題 No.1715 Dinner 2
ユーザー pockynypockyny
提出日時 2021-10-22 23:51:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,149 bytes
コンパイル時間 698 ms
コンパイル使用メモリ 70,244 KB
実行使用メモリ 11,588 KB
最終ジャッジ日時 2023-10-24 16:09:26
合計ジャッジ時間 3,246 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 148 ms
11,476 KB
testcase_12 AC 122 ms
10,496 KB
testcase_13 AC 100 ms
8,448 KB
testcase_14 AC 119 ms
10,496 KB
testcase_15 AC 122 ms
10,496 KB
testcase_16 AC 116 ms
10,492 KB
testcase_17 AC 74 ms
10,492 KB
testcase_18 AC 3 ms
8,112 KB
testcase_19 AC 4 ms
10,428 KB
testcase_20 AC 3 ms
10,156 KB
testcase_21 AC 2 ms
10,156 KB
testcase_22 AC 2 ms
10,160 KB
testcase_23 AC 4 ms
10,164 KB
testcase_24 AC 3 ms
10,160 KB
testcase_25 AC 16 ms
10,468 KB
testcase_26 AC 11 ms
10,212 KB
testcase_27 AC 11 ms
8,176 KB
testcase_28 AC 14 ms
10,616 KB
testcase_29 AC 14 ms
10,648 KB
testcase_30 AC 14 ms
10,552 KB
testcase_31 AC 15 ms
10,452 KB
testcase_32 AC 185 ms
11,588 KB
testcase_33 AC 186 ms
11,588 KB
testcase_34 AC 187 ms
11,588 KB
testcase_35 AC 188 ms
11,588 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
typedef long long ll;
ll p[1010],q[1010],dp[1010][1010],l[1010],r[1010],INF = 10000000000000;
int main(){
    int i,j,n,d; cin >> n >> d;
    for(i=0;i<n;i++) cin >> p[i] >> q[i];
    ll le = -INF,ri = INF;
    while(ri - le>1){
        ll mid = (le + ri)/2;
        for(j=0;j<n;j++){
            if(-p[j]>=mid) dp[0][j] = q[j] - p[j];
            else dp[0][j] = -INF;
        }
        l[0] = -INF,r[n] = -INF;
        for(j=1;j<=n;j++) l[j] = max(l[j - 1],dp[0][j - 1]);
        for(j=n - 1;j>=0;j--) r[j] = max(r[j + 1],dp[0][j]);
        for(i=1;i<d;i++){
            for(j=0;j<n;j++){
                ll mx = max(l[j],r[j + 1]);
                if(mx - p[j]>=mid) dp[i][j] = mx + q[j] - p[j];
                else dp[i][j] = -INF;
            }
            l[0] = -INF,r[n] = -INF;
            for(j=1;j<=n;j++) l[j] = max(l[j - 1],dp[0][j - 1]);
            for(j=n - 1;j>=0;j--) r[j] = max(r[j + 1],dp[0][j]);
        }
        int cnt = 0;
        for(j=0;j<n;j++){
            if(dp[d - 1][j]!=-INF) cnt++;
        }
        if(cnt) le = mid;
        else ri = mid;
    }
    cout << le << endl;
}
0