結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, M;
    cin >> N >> M;
    vector<int> dp(M + 1, 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