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() {
/* ifstream fin("knapsack.in"); */
int s, n;
cin >> s >> n;
long v[2001], w[2001], k[2001];
for (int i = 1; i <= n; i++) {
cin >> v[i] >> w[i] >> k[i];
}
long dp[2001];
for (int i = 1; i <= s; i++) {
dp[i] = dp[i - 1];
for (int j = 1; j <= n; j++) {
if (i >= w[j]) {
dp[i] = max(dp[i], dp[i - w[j]] + v[j]);
}
}
}
cout << dp[s] << '\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... |