結果

問題 No.2093 Shio Ramen
ユーザー kyawakyawa
提出日時 2022-10-07 21:30:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 503 bytes
コンパイル時間 2,054 ms
コンパイル使用メモリ 203,140 KB
実行使用メモリ 11,060 KB
最終ジャッジ日時 2023-09-03 00:24:44
合計ジャッジ時間 3,448 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,444 KB
testcase_10 AC 7 ms
8,320 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 5 ms
6,736 KB
testcase_16 AC 3 ms
4,384 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 9 ms
10,388 KB
testcase_19 AC 6 ms
7,528 KB
testcase_20 AC 4 ms
5,988 KB
testcase_21 AC 6 ms
6,892 KB
testcase_22 AC 5 ms
6,952 KB
testcase_23 AC 10 ms
11,012 KB
testcase_24 AC 10 ms
11,016 KB
testcase_25 AC 10 ms
10,876 KB
testcase_26 AC 9 ms
11,060 KB
testcase_27 AC 9 ms
11,012 KB
testcase_28 AC 9 ms
11,032 KB
testcase_29 AC 9 ms
10,920 KB
testcase_30 AC 10 ms
11,032 KB
権限があれば一括ダウンロードができます

ソースコード

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