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 <iostream>
#include <vector>
using namespace std;
#define mod 1000000007
struct item {
int v, w, k;
};
long long dp[4005],Max;
int s, n;
item a[100005];
int main() {
cin >> s >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].v >> a[i].w >> a[i].k;
a[i].k = min(a[i].k, s / a[i].w);
}
for (int i = 1; i <= n; i++) while (a[i].k--)
for (int j = s; j >= a[i].w; j--) dp[j] = max(dp[j], dp[j - a[i].w] + a[i].v);
for (int i = 1; i <= s; i++) Max = max(Max, dp[i]);
cout << Max;
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... |