結果
問題 | No.1947 質より種類数 |
ユーザー | cho435 |
提出日時 | 2022-05-25 10:01:56 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 815 bytes |
コンパイル時間 | 2,506 ms |
コンパイル使用メモリ | 176,632 KB |
実行使用メモリ | 493,148 KB |
最終ジャッジ日時 | 2023-10-20 19:07:10 |
合計ジャッジ時間 | 9,101 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 751 ms
34,148 KB |
testcase_05 | AC | 408 ms
16,460 KB |
testcase_06 | AC | 441 ms
20,948 KB |
testcase_07 | AC | 566 ms
24,380 KB |
testcase_08 | AC | 945 ms
36,524 KB |
testcase_09 | TLE | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
ソースコード
#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<vector<ll>>> dp(n+1,vector<vector<ll>>(n+1,vector<ll>(p+1,0))); rep(i,n){ rep(k,n){ rep(j,p){ for(ll l=1;j+l*v.at(i)<=p;l++) dp[i+1][k+1][j+l*v.at(i)]=max(dp[i+1][k+1][j+l*v.at(i)],(dp[i][k][j]+l*w.at(i)+c)); dp[i+1][k+1][j+1]=max(dp[i+1][k+1][j+1],dp[i][k+1][j+1]); dp[i+1][k+1][j+1]=max(dp[i+1][k+1][j+1],dp[i+1][k+1][j]); } } /* for(auto dd:dp.at(i+1)){ for(auto d:dd) cout<<d<<" "; cout<<endl; } cout<<endl; */ } ll ans=0; rep(k,n+1) ans=max(dp[n][k][p],ans); cout<<ans<<endl; }