| 26 | ostream &operator<<(ostream &ostream, const vector<T> &c) { for (auto &it : c) { cout << it << " "; } return ostream; } |
| 27 | |
| 28 | int f(int idx, int tar, vector<ll> &cost, vector<ll> &weight,vector<vector<ll>> &dp) { |
| 29 | if (idx == 0) { |
| 30 | if (tar >= cost[0]) return weight[0]; |
| 31 | return 0; |
| 32 | } |
| 33 | if (dp[idx][tar] != -1) return dp[idx][tar]; |
| 34 | int notake = f(idx-1,tar,cost,weight,dp); |
| 35 | int take = 0; |
| 36 | if (tar >= cost[idx]) take = f(idx-1,tar - cost[idx], cost, weight,dp) + weight[idx]; |
| 37 | return dp[idx][tar] = max(take , notake); |
| 38 | } |
| 39 | |
| 40 | void solve() { |
| 41 | int n, x; cin >> n >> x; |