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;
using ll = long long;
int v[100100], w[100100], k[100100];
int dp[2020];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int s, n;
cin >> s >> n;
for (int i = 1;i <= n;i++) {
cin >> v[i] >> w[i] >> k[i];
k[i] = min(k[i], s / w[i]);
while (k[i]--) {
for (int j = 2000;j >= w[i];j--) {
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
}
}
}
cout << (*max_element(dp, dp + s + 1));
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... |