結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 4 ms
4,704 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 75 ms
32,896 KB
testcase_12 AC 77 ms
33,184 KB
testcase_13 AC 70 ms
31,292 KB
testcase_14 AC 14 ms
9,904 KB
testcase_15 AC 57 ms
27,884 KB
testcase_16 AC 91 ms
36,872 KB
testcase_17 AC 18 ms
11,356 KB
testcase_18 AC 96 ms
37,756 KB
testcase_19 AC 76 ms
33,060 KB
testcase_20 AC 21 ms
13,064 KB
testcase_21 AC 11 ms
8,452 KB
testcase_22 AC 19 ms
12,096 KB
testcase_23 AC 5 ms
5,148 KB
testcase_24 AC 60 ms
28,896 KB
testcase_25 AC 100 ms
38,616 KB
testcase_26 AC 100 ms
38,544 KB
testcase_27 AC 99 ms
38,492 KB
testcase_28 AC 100 ms
38,712 KB
testcase_29 AC 99 ms
38,592 KB
testcase_30 AC 100 ms
38,560 KB
testcase_31 AC 100 ms
38,708 KB
testcase_32 AC 101 ms
38,608 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[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