| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1335295 | isaacsun | Knapsack (NOI18_knapsack) | C++20 | 1074 ms | 456 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, numItems;
cin >> maxWeight >> numItems;
vector<int> dp(maxWeight + 1);
for(int i = 0; i < numItems; i++) {
int value, weight, copies;
cin >> value >> weight >> copies;
copies = min(copies, maxWeight / weight);
int part = 1;
while(copies > 0) {
int size = min(part, copies);
int w = weight * size;
int v = value * size;
for(int j = maxWeight; j - w >= 0; j--) {
dp[j] = max(dp[j], dp[j - w] + v);
}
copies -= part;
part <<= 1;
}
}
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... | ||||
