#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf = -1e16;
#define sc second
#define fr first
#define all(x) x.begin(),x.end()
#define roll(x) x.rbegin(),x.rend()
#define pb push_back
#define el '\n'
const ll mod = 1e9 + 7;
void solve() {
ll n,k;cin >> n >> k;
vector<ll> dp(k+1,-inf);
dp[0] = 0;
while(n--){
ll v,w,s;cin >> v >> w >> s;
for(ll t = 0;t<s;t++){
for(ll i = k;i>=v;i--){
dp[i] = max(dp[i],dp[i-v] + w);
}
}
}
cout << dp[k];
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
/*ll t;cin >>t;
while (t--)*/solve();
return 0;
};
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |