結果

問題 No.2093 Shio Ramen
ユーザー 7iz67iz6
提出日時 2022-10-21 23:20:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 680 bytes
コンパイル時間 869 ms
コンパイル使用メモリ 71,824 KB
実行使用メモリ 7,588 KB
最終ジャッジ日時 2023-09-13 23:28:20
合計ジャッジ時間 4,900 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,304 KB
testcase_01 AC 4 ms
7,360 KB
testcase_02 AC 4 ms
7,368 KB
testcase_03 AC 5 ms
7,324 KB
testcase_04 AC 5 ms
7,484 KB
testcase_05 AC 5 ms
7,584 KB
testcase_06 AC 5 ms
7,344 KB
testcase_07 AC 5 ms
7,336 KB
testcase_08 AC 4 ms
7,296 KB
testcase_09 AC 5 ms
7,356 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 5 ms
7,368 KB
testcase_13 AC 5 ms
7,312 KB
testcase_14 AC 5 ms
7,460 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 6 ms
7,352 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 6 ms
7,424 KB
testcase_21 AC 6 ms
7,348 KB
testcase_22 AC 7 ms
7,588 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

struct Ramen {
    int s, a;
};

int main() {
    int N, I; cin >> N >> I;
    Ramen r[N];
    vector<vector<int>> dp(1006, vector<int>(1006, -1));
    for(int i = 0; i < N; i++) {
        cin >> r[i].s >> r[i].a;
    }
    dp[0][0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= I; j++) {
            if(dp[i][j] == -1) continue;
            dp[i + 1][r[i].s + j] = max(dp[i + 1][r[i].s + j], dp[i][j] + r[i].a);
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }
    int ans = 0;
    for(int i = 0; i <= I; i++) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << endl;
}
0