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;
int S, N, items[100000][3];
int dp[2001];
int main() {
cin >> S >> N;
for(int i = 0; i < N; i++) {
// cin >> items[i][0] >> items[i][1] >> items[i][2];
int V, W, K;
cin >> V >> W >> K;
for(int i = 1; i <= K && i*W <= S; i++) dp[S] = max(dp[S], dp[S-W*i] + V*i);
for(int s = S-1; s >= 1; s--) {
if(W * K <= s) dp[s] = max(dp[s], dp[s-W*K] + V*K);
}
}
cout << dp[S] << endl;
}
# | 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... |