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 main() {
int s, n;
cin >> s >> n;
int dp[2001];
for (int i = 0; i <= s; i++) {
dp[i] = -1;
}
dp[0] = 0;
for (int i = 1; i <= n; i++) {
int v, w, k;
cin >> v >> w >> k;
for (int x = s; x >= 0; x--) {
if (dp[x] != -1) {
dp[x + w] = dp[x] + v;
}
}
}
int res = 0;
for (int i = 0; i <= s; i++) {
res = max(res, dp[i]);
}
cout << res << '\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... |