結果

問題 No.2093 Shio Ramen
ユーザー nyyanyya
提出日時 2022-10-07 21:53:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,016 bytes
コンパイル時間 3,982 ms
コンパイル使用メモリ 229,192 KB
実行使用メモリ 11,148 KB
最終ジャッジ日時 2023-09-03 01:37:55
合計ジャッジ時間 5,334 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,440 KB
testcase_10 AC 7 ms
8,324 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 6 ms
6,740 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 9 ms
10,496 KB
testcase_19 AC 6 ms
7,560 KB
testcase_20 AC 4 ms
5,972 KB
testcase_21 AC 5 ms
6,812 KB
testcase_22 AC 5 ms
6,724 KB
testcase_23 AC 9 ms
11,064 KB
testcase_24 AC 9 ms
11,012 KB
testcase_25 AC 9 ms
10,964 KB
testcase_26 AC 9 ms
11,148 KB
testcase_27 AC 10 ms
11,016 KB
testcase_28 AC 10 ms
10,964 KB
testcase_29 AC 10 ms
10,964 KB
testcase_30 AC 9 ms
10,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
//using mint = modint;
using mint = modint998244353;
using P = pair<int, int>;

const ll INF=1LL<<60, dx[]={0,1,0,-1},dy[]={1,0,-1,0};
bool chmin(ll& a,ll b){if(a>b){a=b; return 1;} return 0;}
bool chmax(ll& a,ll b){if(a<b){a=b; return 1;} return 0;}

int main(){

    int n,maxi;
    cin >> n >> maxi;
    vector<int> s(n),a(n);

    rep(i,n) cin >> s[i] >> a[i];

    vector<vector<ll>> dp(n+1,vector<ll> (maxi+1,-INF));
    dp[0][0]=0;

    for(int i=1;i<=n;i++){
        rep(j,maxi+1){
            if(j-s[i-1]>=0) dp[i][j]=max(dp[i-1][j-s[i-1]]+a[i-1],dp[i-1][j]);
            else dp[i][j]=dp[i-1][j];
        }
    }

    /*
    rep(i,n+1){
        rep(j,maxi+1) {
            cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    */
    
    ll ans = 0;
    rep(i,maxi+1) chmax(ans,dp[n][i]);
    cout << ans << endl;
 

    return 0;
}
0