結果

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
    int64_t N, I; cin >> N >> I;
    vector dp(N+1, vector(I+1, int64_t(0)));
    for(int64_t i = 1; i <= N; i++){
        int64_t s, a; cin >> s >> a;
        for(int64_t j = 0; j <= I; j++){
            if(j+s <= I) dp[i][j+s] = max(dp[i][j+s], dp[i-1][j] + a);
        }
        for(int64_t j = 0; j <= I; j++){
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
        }
    }
    cout << *max_element(dp[N].begin(), dp[N].end()) << '\n';
}
0