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;
struct item {
int weight, price, count;
};
int main() {
int s, n;
cin >> s >> n;
vector<item> items(n);
for (int i = 0; i < n; ++i) {
cin >> items[i].price >> items[i].weight >> items[i].count;
}
vector<int> dp(s + 1, 0);
for (int i = 0; i < n; ++i) {
for (int x = s; x >=0; --x) {
int top = min((s - x) / items[i].weight, items[i].count);
dp[x + top * items[i].weight] = max(dp[x + top * items[i].weight],
dp[x] + items[i].price * top);
}
}
cout << dp[s] << "\n";
}
# | 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... |