結果

問題 No.1947 質より種類数
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-29 14:44:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 609 bytes
コンパイル時間 2,180 ms
コンパイル使用メモリ 205,472 KB
実行使用メモリ 814,556 KB
最終ジャッジ日時 2023-09-20 10:08:12
合計ジャッジ時間 8,742 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 14 ms
10,688 KB
testcase_05 AC 10 ms
8,112 KB
testcase_06 AC 11 ms
8,384 KB
testcase_07 AC 12 ms
9,420 KB
testcase_08 AC 14 ms
10,740 KB
testcase_09 AC 54 ms
33,668 KB
testcase_10 AC 37 ms
24,496 KB
testcase_11 AC 118 ms
72,416 KB
testcase_12 AC 80 ms
50,524 KB
testcase_13 AC 31 ms
20,256 KB
testcase_14 AC 639 ms
384,992 KB
testcase_15 AC 326 ms
196,868 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){

    ll N, V, C;
    cin >> N >> V >> C;
    vector<ll> v(N+1), w(N+1);
    vector<vector<vector<ll>>> dp(N+1, vector(V+1, vector<ll>(2)));
    for (int i=1; i<=N; i++) cin >> v[i] >> w[i];

    for (int i=1; i<=N; i++){
        for (int j=0; j<=V; j++){
            dp[i][j][0] = max({dp[i][j][0], dp[i-1][j][0], dp[i-1][j][1]});
            if (j-v[i] >= 0) dp[i][j][1] = max({dp[i][j][1], dp[i][j-v[i]][0]+w[i]+C, dp[i][j-v[i]][1]+w[i]});
        }
    }

    cout << max(dp[N][V][0], dp[N][V][1]) << endl;

    return 0;
}
0