結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー face4face4
提出日時 2019-12-12 10:14:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,500 ms
コード長 813 bytes
コンパイル時間 749 ms
コンパイル使用メモリ 70,500 KB
実行使用メモリ 38,628 KB
最終ジャッジ日時 2023-09-07 01:34:07
合計ジャッジ時間 3,707 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 4 ms
4,720 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 77 ms
33,116 KB
testcase_12 AC 78 ms
33,192 KB
testcase_13 AC 70 ms
31,340 KB
testcase_14 AC 15 ms
9,928 KB
testcase_15 AC 57 ms
27,908 KB
testcase_16 AC 93 ms
36,896 KB
testcase_17 AC 18 ms
11,456 KB
testcase_18 AC 97 ms
37,804 KB
testcase_19 AC 76 ms
33,016 KB
testcase_20 AC 22 ms
13,120 KB
testcase_21 AC 12 ms
8,524 KB
testcase_22 AC 19 ms
12,132 KB
testcase_23 AC 5 ms
5,308 KB
testcase_24 AC 61 ms
28,748 KB
testcase_25 AC 101 ms
38,584 KB
testcase_26 AC 100 ms
38,508 KB
testcase_27 AC 100 ms
38,620 KB
testcase_28 AC 101 ms
38,568 KB
testcase_29 AC 101 ms
38,536 KB
testcase_30 AC 100 ms
38,508 KB
testcase_31 AC 101 ms
38,628 KB
testcase_32 AC 100 ms
38,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 難易度が低い方から解くとして良い
#include<iostream>
#include<algorithm>
using namespace std;

int dp[3001][3001] = {};

int main(){
    int n;
    cin >> n;
    int a[n+1], b[n+1], d[n+1];
    for(int i = 0; i <= n; i++) cin >> a[i];
    for(int i = 0; i <= n; i++) cin >> b[i];
    reverse(a, a+n+1);
    reverse(b, b+n+1);
    for(int i = 0; i < n; i++)  cin >> d[i];
    d[n] = 1<<30;
    sort(d, d+n+1);
    dp[0][0] = a[0]+b[0] >= d[0] ? 1 : 0;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            if(i+1 <= n)    dp[i+1][j] = max(dp[i+1][j], dp[i][j]+(a[i+1]+b[j] >= d[dp[i][j]]));
            if(j+1 <= n)    dp[i][j+1] = max(dp[i][j+1], dp[i][j]+(a[i]+b[j+1] >= d[dp[i][j]]));
        }
    }
    cout << max(dp[n-1][n], dp[n][n-1]) << endl;
    return 0;
}
0