| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1341231 | kiengyt | Knapsack (NOI18_knapsack) | C++20 | 1096 ms | 432 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int S_MAX = 100005;
ll dp[S_MAX];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int s, n;
if (!(cin >> s >> n)) return 0;
fill(dp, dp + s + 1, 0);
for (int i = 0; i < n; i++) {
ll v_i, w_i, k_i;
cin >> v_i >> w_i >> k_i;
for (ll j = 1; k_i > 0; j <<= 1) {
ll num = min(j, k_i);
ll V = num * v_i;
ll W = num * w_i;
for (int j_s = s; j_s >= W; j_s--) {
if (dp[j_s - W] + V > dp[j_s]) {
dp[j_s] = dp[j_s - W] + V;
}
}
k_i -= num;
}
}
ll ans = 0;
for (int j = 0; j <= s; j++) ans = max(ans, dp[j]);
cout << ans;
return 0;
}| # | 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... | ||||
