| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1333466 | isaacsun | Knapsack (NOI18_knapsack) | C++20 | 1095 ms | 440 KiB |
// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int maxWeight, items;
cin >> maxWeight >> items;
vector<int> dp(maxWeight + 1);
for(int i = 0; i < items; i++) {
int value, weight, quantity;
cin >> value >> weight >> quantity;
for(int i = maxWeight; i >= weight; i--) {
int maxValue = 0;
for(int j = 0; j <= quantity; j++) {
if(i - weight * j < 0) {
break;
}
maxValue = max(maxValue, dp[i - weight * j] + value * j);
}
dp[i] = maxValue;
}
}
cout << dp[maxWeight];
}| # | 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... | ||||
