結果

問題 No.2093 Shio Ramen
ユーザー otoshigootoshigo
提出日時 2022-10-07 21:26:33
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 3,095 ms
コンパイル使用メモリ 199,324 KB
実行使用メモリ 7,408 KB
最終ジャッジ日時 2023-09-03 00:03:01
合計ジャッジ時間 4,677 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 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 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,500 KB
testcase_10 AC 5 ms
6,604 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 3 ms
5,844 KB
testcase_13 AC 3 ms
6,120 KB
testcase_14 AC 3 ms
6,404 KB
testcase_15 AC 4 ms
6,340 KB
testcase_16 AC 2 ms
4,440 KB
testcase_17 AC 4 ms
7,300 KB
testcase_18 AC 6 ms
7,296 KB
testcase_19 AC 5 ms
7,320 KB
testcase_20 AC 5 ms
7,308 KB
testcase_21 AC 5 ms
7,352 KB
testcase_22 AC 5 ms
7,296 KB
testcase_23 AC 6 ms
7,408 KB
testcase_24 AC 6 ms
7,392 KB
testcase_25 AC 5 ms
7,328 KB
testcase_26 AC 6 ms
7,276 KB
testcase_27 AC 6 ms
7,344 KB
testcase_28 AC 6 ms
7,272 KB
testcase_29 AC 6 ms
7,284 KB
testcase_30 AC 6 ms
7,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = (n) - 1; i >= 0; i--)

int n,m,dp[1010][1010];
int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cin>>n>>m;
    rep(i,n+1)rep(j,m+1)dp[i][j]=-1<<30;
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        int s,a;
        cin>>s>>a;
        rep(j,m+1){
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
            if(j-s>=0)dp[i][j]=max(dp[i][j],dp[i-1][j-s]+a);
        }
    }
    int ans=0;
    rep(i,m+1)ans=max(ans,dp[n][i]);
    cout<<ans<<"\n";
}
0