#include <bits/stdc++.h>
#define maxn 1003
#define pii pair<ll, ll>
#define tpe tuple<int, int, int>
#define MOD 1000000007
#define ll long long
#define lim 44725
#define file "mind"
#define base 131
using namespace std;
int n, c;
ll d[maxn][maxn];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> c;
for(int i = 1; i <= n; i++) {
int w, v, k;
cin >> w >> v >> k;
for(int j = 0; j <= c; j++) {
d[i][j] = d[i-1][j];
for(int t = 1; t <= k; t++) {
if(j >= w * t) d[i][j] = max(d[i][j], d[i-1][j-w*t] + v * t);
}
}
}
cout << d[n][c];
}
| # | 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... |