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;
const int mxn = 1e5 + 10;
const int mxs = 2000 + 9;
int dp[mxn][mxs], n, s, ans;
int pr[mxn], we[mxn], am[mxn];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> s >> n;
for(int i = 1; i <= n; i++)
cin >> pr[i] >> we[i] >> am[i];
for(int i = 1; i <= n; i++)
for(int j = 0; j <= s; j++) {
for(int k = 0; k <= am[i] && k * we[i] <= j; k++)
dp[i][j] = max(dp[i][j], dp[i-1][j - we[i] * k] + pr[i] * k);
ans = max(ans, dp[i][j]);
}
cout << ans << '\n';
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... |