結果

問題 No.2093 Shio Ramen
ユーザー Carpenters-Cat
提出日時 2022-10-07 21:38:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 543 bytes
コンパイル時間 1,915 ms
コンパイル使用メモリ 194,604 KB
最終ジャッジ日時 2025-02-07 23:00:49
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 15 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, M;
    cin >> N >> M;
    vector<int> dp(M, 0);
    for (int i = 0; i < N; i ++) {
        int s, a;
        cin >> s >> a;
        if (s > M) {
            continue;
        }
        for (int j = M; j >= s; j --) {
            dp[j] = max(dp[j], dp[j - s] + a);
        }
        for (int j = 1; j <= M; j ++) {
            dp[j] = max(dp[j], dp[j - 1]);
        }
    }
    int ans = 0;
    for (int d : dp) {
        ans = max(ans, d);
    }
    cout << ans << endl;
}
0