| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1361409 | fly | Knapsack (NOI18_knapsack) | C++20 | 1095 ms | 444 KiB |
#include <bits/stdc++.h>
using namespace std;
long long dp[2001];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
memset(dp, 0x80, sizeof(dp));
int n, s;
cin >> s >> n;
dp[s] = 0;
int v, w, k;
for (int q = 0; q < n; q++) {
cin >> v >> w >> k;
for (int i = 1; i <= s; i++) {
for (int num = 1; num <= k; num++) {
if (i-(num*w) < 0) break;
dp[i-(num*w)] = max(dp[i-(num*w)], dp[i]+(num*v));
}
}
}
long long answer = 0;
for (int i = 0; i < s; i++) answer = max(answer, dp[i]);
cout << answer;
}| # | 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... | ||||
