結果

問題 No.2093 Shio Ramen
ユーザー _yurimoir_yurimoir
提出日時 2022-10-07 21:45:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 758 bytes
コンパイル時間 1,948 ms
コンパイル使用メモリ 167,568 KB
実行使用メモリ 7,572 KB
最終ジャッジ日時 2023-09-03 01:12:58
合計ジャッジ時間 3,154 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,384 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 WA -
testcase_16 AC 3 ms
4,384 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 5 ms
5,704 KB
testcase_20 WA -
testcase_21 AC 4 ms
5,144 KB
testcase_22 AC 4 ms
5,076 KB
testcase_23 WA -
testcase_24 AC 6 ms
7,328 KB
testcase_25 AC 6 ms
7,276 KB
testcase_26 AC 6 ms
7,336 KB
testcase_27 WA -
testcase_28 AC 6 ms
7,392 KB
testcase_29 WA -
testcase_30 AC 6 ms
7,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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