This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
ll dp[100001][2001];
int32_t main() {
ios_base::sync_with_stdio(false); cin.tie(0);
ll N, W; cin >> W >> N; ll w[N], v[N], K[N];
for(ll i = 0; i < N; i++) {
cin >> v[i] >> w[i] >> K[i];
}
for(ll i = 1; i <= N; i++) {
for(ll j = 1; j <= W; j++) {
for(ll k = 0; k * w[i - 1] <= j && k <= K[i - 1]; k++) {dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i-1] * k] + v[i-1] * k);}
}
}
cout << dp[N][W];
}
# | 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... |