結果

問題 No.2093 Shio Ramen
ユーザー _yurimoir_yurimoir
提出日時 2022-10-07 22:17:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 770 bytes
コンパイル時間 2,282 ms
コンパイル使用メモリ 167,432 KB
実行使用メモリ 11,428 KB
最終ジャッジ日時 2023-09-03 13:12:29
合計ジャッジ時間 3,433 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 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
5,068 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 5 ms
7,936 KB
testcase_20 WA -
testcase_21 AC 4 ms
6,768 KB
testcase_22 AC 3 ms
6,960 KB
testcase_23 WA -
testcase_24 AC 6 ms
11,256 KB
testcase_25 AC 6 ms
11,316 KB
testcase_26 AC 5 ms
11,200 KB
testcase_27 WA -
testcase_28 AC 5 ms
11,192 KB
testcase_29 WA -
testcase_30 AC 5 ms
11,172 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][l+1];
    for(ll i=0;i<n;i++){
        for(ll j=0;j<l+1;j++){
            dp[i][j]=0;
        }
    }
    dp[0][s[0]]=a[0];
    for(ll i=1;i<n;i++){
        for(ll 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]]);
            }
        }
    }
    ll ans=0;
    for(ll i=l;i>=0;i--){
        if(dp[n-1][i]!=0){
            ans=dp[n-1][i];
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}
0