結果

問題 No.1947 質より種類数
ユーザー keisuke6keisuke6
提出日時 2022-05-20 22:47:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 1,799 ms
コンパイル使用メモリ 172,228 KB
実行使用メモリ 198,924 KB
最終ジャッジ日時 2023-10-20 13:38:04
合計ジャッジ時間 4,876 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 3 ms
4,372 KB
testcase_05 AC 3 ms
4,372 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 3 ms
4,372 KB
testcase_08 AC 3 ms
4,372 KB
testcase_09 AC 6 ms
7,788 KB
testcase_10 AC 5 ms
6,468 KB
testcase_11 AC 12 ms
13,332 KB
testcase_12 AC 9 ms
10,164 KB
testcase_13 AC 5 ms
5,676 KB
testcase_14 AC 57 ms
57,948 KB
testcase_15 AC 30 ms
31,020 KB
testcase_16 AC 80 ms
83,028 KB
testcase_17 AC 104 ms
106,788 KB
testcase_18 AC 190 ms
188,628 KB
testcase_19 AC 163 ms
164,868 KB
testcase_20 AC 123 ms
124,476 KB
testcase_21 AC 143 ms
146,388 KB
testcase_22 AC 10 ms
11,220 KB
testcase_23 AC 65 ms
67,188 KB
testcase_24 AC 3 ms
4,884 KB
testcase_25 AC 3 ms
4,372 KB
testcase_26 AC 3 ms
4,372 KB
testcase_27 AC 2 ms
4,372 KB
testcase_28 AC 3 ms
4,372 KB
testcase_29 AC 227 ms
198,924 KB
testcase_30 AC 225 ms
198,924 KB
testcase_31 AC 1 ms
4,372 KB
testcase_32 AC 2 ms
4,372 KB
testcase_33 AC 2 ms
4,372 KB
testcase_34 AC 182 ms
198,924 KB
testcase_35 AC 180 ms
198,924 KB
testcase_36 AC 224 ms
198,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,V,C;
  cin>>N>>V>>C;
  vector<int> v(N),w(N);
  for(int i=0;i<N;i++) cin>>v[i]>>w[i];
  vector<vector<int>> dp(N+1,vector<int>(V+1));
  for(int i=1;i<=N;i++){
    for(int j=0;j<=V;j++){
      int ans = dp[i-1][j];
      if(v[i-1] <= j) ans = max(max(ans,dp[i][j-v[i-1]]+w[i-1]),dp[i-1][j-v[i-1]]+w[i-1]+C);
      dp[i][j] = ans;
    }
  }
  int ans = -1;
 /*for(int i=0;i<=N;i++){
    for(int j=0;j<=V;j++){
      cout<<dp[i][j]<<' ';
    }
    cout<<endl;
  }*/
  for(int i=0;i<=V;i++) ans = max(ans,dp[N][i]);
  cout<<ans<<endl;
}
0