結果

問題 No.2093 Shio Ramen
ユーザー _yurimoir_yurimoir
提出日時 2022-10-08 09:30:51
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 2,920 ms
コンパイル使用メモリ 245,072 KB
実行使用メモリ 11,368 KB
最終ジャッジ日時 2023-09-04 08:46:53
合計ジャッジ時間 4,719 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 6 ms
8,568 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 5 ms
7,200 KB
testcase_16 AC 3 ms
4,840 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 6 ms
10,852 KB
testcase_19 AC 5 ms
7,860 KB
testcase_20 AC 3 ms
5,824 KB
testcase_21 AC 4 ms
6,792 KB
testcase_22 AC 5 ms
6,540 KB
testcase_23 AC 6 ms
11,228 KB
testcase_24 AC 6 ms
11,168 KB
testcase_25 AC 7 ms
11,092 KB
testcase_26 AC 7 ms
11,368 KB
testcase_27 AC 6 ms
11,208 KB
testcase_28 AC 6 ms
11,204 KB
testcase_29 AC 6 ms
11,252 KB
testcase_30 AC 7 ms
11,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ll n,l;
    cin>>n>>l;
    vector<ll> s(n),a(n);
    for(ll i=0;i<n;i++){
        cin>>s[i]>>a[i];
    }
    ll dp[n+1][l+1];
    for(ll i=0;i<n;i++){
        for(ll j=0;j<l+1;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<n+1;i++){
        for(int j=0;j<l+1;j++){
            if(i==0||j==0){
                dp[i][j]=0;
            }else if(s[i-1]<=j){
                dp[i][j]=max(a[i-1]+dp[i-1][j-s[i-1]],dp[i-1][j]);
            }else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][l]<<endl;
    return 0;
}
0