結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー face4face4
提出日時 2019-12-12 10:20:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 2,500 ms
コード長 812 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 70,952 KB
実行使用メモリ 38,788 KB
最終ジャッジ日時 2023-09-07 01:36:52
合計ジャッジ時間 3,496 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 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,380 KB
testcase_08 AC 4 ms
4,748 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
4,384 KB
testcase_11 AC 75 ms
32,924 KB
testcase_12 AC 75 ms
33,224 KB
testcase_13 AC 68 ms
31,512 KB
testcase_14 AC 13 ms
9,972 KB
testcase_15 AC 56 ms
27,872 KB
testcase_16 AC 91 ms
36,856 KB
testcase_17 AC 17 ms
11,432 KB
testcase_18 AC 95 ms
37,804 KB
testcase_19 AC 75 ms
33,124 KB
testcase_20 AC 21 ms
13,040 KB
testcase_21 AC 11 ms
8,436 KB
testcase_22 AC 18 ms
12,156 KB
testcase_23 AC 4 ms
5,160 KB
testcase_24 AC 60 ms
28,848 KB
testcase_25 AC 98 ms
38,604 KB
testcase_26 AC 98 ms
38,572 KB
testcase_27 AC 98 ms
38,788 KB
testcase_28 AC 98 ms
38,652 KB
testcase_29 AC 100 ms
38,544 KB
testcase_30 AC 99 ms
38,544 KB
testcase_31 AC 99 ms
38,592 KB
testcase_32 AC 99 ms
38,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n+1], b[n+1], d[n+1];
    for(int i = 0; i <= n; i++) cin >> a[n-i];
    for(int i = 0; i <= n; i++) cin >> b[n-i];
    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];
    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