Submission #507555

#TimeUsernameProblemLanguageResultExecution timeMemory
507555FrostByteKnapsack (NOI18_knapsack)C++17
73 / 100
1062 ms2204 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...