結果

問題 No.2093 Shio Ramen
ユーザー umezoumezo
提出日時 2022-10-07 22:25:05
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 1,899 ms
コンパイル使用メモリ 199,932 KB
実行使用メモリ 7,572 KB
最終ジャッジ日時 2023-09-03 13:29:58
合計ジャッジ時間 3,394 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,304 KB
testcase_01 AC 4 ms
7,432 KB
testcase_02 AC 4 ms
7,308 KB
testcase_03 AC 4 ms
7,380 KB
testcase_04 AC 4 ms
7,320 KB
testcase_05 AC 5 ms
7,356 KB
testcase_06 AC 5 ms
7,380 KB
testcase_07 AC 4 ms
7,352 KB
testcase_08 AC 4 ms
7,364 KB
testcase_09 AC 5 ms
7,360 KB
testcase_10 AC 6 ms
7,420 KB
testcase_11 AC 4 ms
7,436 KB
testcase_12 AC 5 ms
7,408 KB
testcase_13 AC 4 ms
7,388 KB
testcase_14 AC 4 ms
7,316 KB
testcase_15 AC 5 ms
7,488 KB
testcase_16 AC 5 ms
7,360 KB
testcase_17 AC 5 ms
7,364 KB
testcase_18 AC 6 ms
7,500 KB
testcase_19 AC 5 ms
7,488 KB
testcase_20 AC 5 ms
7,420 KB
testcase_21 AC 6 ms
7,380 KB
testcase_22 AC 5 ms
7,332 KB
testcase_23 AC 6 ms
7,572 KB
testcase_24 AC 6 ms
7,376 KB
testcase_25 AC 6 ms
7,412 KB
testcase_26 AC 7 ms
7,548 KB
testcase_27 AC 6 ms
7,372 KB
testcase_28 AC 6 ms
7,460 KB
testcase_29 AC 6 ms
7,424 KB
testcase_30 AC 7 ms
7,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int dp[1010][1010];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  rep(i,1010) rep(j,1010) dp[i][j]=-1;
  
  int n,I;
  cin>>n>>I;
  vector<int> S(n),A(n);
  rep(i,n) cin>>S[i]>>A[i];
  dp[0][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=I;j++){
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
      if(j+S[i]<=I) dp[i+1][j+S[i]]=max(dp[i+1][j+S[i]],dp[i][j]+A[i]);
    }
  }
  int ma=0;
  for(int j=0;j<=I;j++){
    ma=max(ma,dp[n][j]);
  }
  cout<<ma<<endl;
  
  return 0;
}
0