結果

問題 No.1947 質より種類数
ユーザー cho435cho435
提出日時 2022-05-25 10:14:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 796 bytes
コンパイル時間 1,634 ms
コンパイル使用メモリ 174,208 KB
実行使用メモリ 398,944 KB
最終ジャッジ日時 2023-10-20 19:07:48
合計ジャッジ時間 10,106 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 30 ms
5,400 KB
testcase_05 AC 27 ms
4,608 KB
testcase_06 AC 22 ms
4,872 KB
testcase_07 AC 31 ms
5,136 KB
testcase_08 AC 35 ms
5,400 KB
testcase_09 AC 37 ms
12,000 KB
testcase_10 AC 26 ms
9,360 KB
testcase_11 AC 83 ms
23,088 KB
testcase_12 AC 55 ms
16,752 KB
testcase_13 AC 22 ms
8,040 KB
testcase_14 AC 222 ms
112,584 KB
testcase_15 AC 109 ms
58,464 KB
testcase_16 AC 320 ms
162,744 KB
testcase_17 AC 402 ms
210,264 KB
testcase_18 AC 731 ms
373,680 KB
testcase_19 AC 629 ms
326,424 KB
testcase_20 AC 475 ms
245,640 KB
testcase_21 AC 559 ms
289,464 KB
testcase_22 AC 33 ms
19,128 KB
testcase_23 AC 256 ms
131,064 KB
testcase_24 AC 88 ms
6,192 KB
testcase_25 AC 69 ms
5,400 KB
testcase_26 AC 40 ms
4,348 KB
testcase_27 AC 53 ms
4,872 KB
testcase_28 AC 80 ms
5,400 KB
testcase_29 TLE -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  int n,p,c;
  cin>>n>>p>>c;
  vector<int> v(n);
  vector<int> w(n);
  rep(i,n) cin>>v.at(i)>>w.at(i);
  vector<vector<ll>> dp(2*n+1,vector<ll>(p+1,0));
  rep(i,n){
    rep(j,p){
      for(ll l=1;j+l*v.at(i)<=p;l++) dp[i+1][j+l*v.at(i)]=max(dp[i+1][j+l*v.at(i)],dp[i][j]+l*w.at(i));
      dp[i+1][j+1]=max(dp[i+1][j+1],max(dp[i][j+1],dp[i+1][j]));
    }
  }
  rep(i,n){
    rep(j,p){
      if(j+v.at(i)<=p) dp[n+i+1][j+v.at(i)]=max(dp[n+i+1][j+v.at(i)],dp[n+i][j]+w.at(i)+c);
      dp[n+i+1][j+1]=max(dp[n+i+1][j+1],max(dp[n+i][j+1],dp[n+i+1][j]));
    }
  }
  /*
  for(auto dd:dp){
    for(auto d:dd) cout<<d<<" ";
    cout<<endl;
  }
  */
  cout<<dp[2*n][p]<<endl;
}
0