結果

問題 No.617 Nafmo、買い出しに行く
ユーザー CleyLCleyL
提出日時 2020-01-22 19:54:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 69,848 KB
実行使用メモリ 40,264 KB
最終ジャッジ日時 2023-09-22 22:55:19
合計ジャッジ時間 1,864 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 32 ms
34,012 KB
testcase_06 AC 60 ms
40,264 KB
testcase_07 AC 58 ms
40,148 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 46 ms
40,144 KB
testcase_11 AC 53 ms
40,156 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
bool dp[20][2000001];
int main(){
    int n,k;cin>>n>>k;
    vector<int> a(n);
    for(int i = 0; n > i; i++){
        cin>>a[i];
    }
    dp[0][0] = true;
    dp[0][a[0]] = true;
    for(int i = 1; n > i; i++){
        for(int j = 0; k >= j; j++){
            if(dp[i-1][j]){
                dp[i][j+a[i]]=true;
            }
        }
    }
    for(int i = k; 0 <= i; i--){
        if(dp[n-1][i]){
            cout << i << endl;
            return 0;
        }
    }
}
0