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;
int main() {
int max_weight, num_items;
cin >> max_weight >> num_items;
int item_info[num_items][3];
for (int i = 0; i < num_items; i++) {
cin >> item_info[i][0] >> item_info[i][1] >> item_info[i][2];
item_info[i][2] = min(item_info[i][2], max_weight / item_info[i][1]);
}
int max_val_for_weight[2001] = {0};
for (int i = 0; i < num_items; i++) {
for (int j = 0; j < item_info[i][2]; j++) {
for (int k = max_weight; k >= 0; k--) {
if (k - item_info[i][1] >= 0) {
max_val_for_weight[k] = max(max_val_for_weight[k], max_val_for_weight[k - item_info[i][1]] + item_info[i][0]);
}
}
}
}
cout << max_val_for_weight[max_weight] << endl;
}
# | 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... |