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>
using namespace std;
struct Kue {
long long value, weight, stock;
};
int main() {
int s, n;
cin >> s >> n;
Kue kue[n];
long long max_weight = 0;
for (int i = 0; i < n; i++) {
cin >> kue[i].value >> kue[i].weight >> kue[i].stock;
(kue[i].weight > max_weight) && (max_weight = kue[i].weight);
}
long long dp[s + 1] = {0};
int k = 0;
for (int i = 0; i < n; i++) {
for (int w = s; w >= 0; w--) {
if (kue[i].weight > w) break;
k = min(w / kue[i].weight, kue[i].stock);
dp[w] = max(dp[w], dp[w - k * kue[i].weight] + k * kue[i].value);
}
}
cout << dp[s];
}
# | 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... |