| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1364335 | thisisadarsh | Knapsack (NOI18_knapsack) | C++20 | 1093 ms | 2756 KiB |
#include <iostream>
#include <vector>
#include <array>
#include <cstdint>
using namespace std;
#define int int64_t
int32_t main() {
int n, m;
cin >> n >> m;
vector<array<int,3>> a(m);
for (int i = 0; i < m; i++) {
cin >> a[i][0] >> a[i][1] >> a[i][2];
}
vector<int> dp(n + 1, 0);
for (int i = 0; i < m; i++) {
int value = a[i][0];
int weight = a[i][1];
int copies = a[i][2];
for (int w = n; w >= 0; w--) {
for (int k = 1; k <= copies; k++) {
int need = k * weight;
if (need > w) break;
dp[w] = max(dp[w], dp[w - need] + k * value);
}
}
}
cout << dp[n] << '\n';
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
