| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1132324 | viwlesxq | Knapsack (NOI18_knapsack) | C++20 | 1093 ms | 2632 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int s, n; cin >> s >> n;
int v[n], w[n], k[n];
for (int i = 0; i < n; ++i)
cin >> v[i] >> w[i] >> k[i];
int dp[s + 1];
memset(dp, 0, sizeof(dp));
for (int i = 0; i < n; ++i) {
for (int j = 1; j * w[i] <= s && j <= k[i]; ++j) {
for (int p = s; p >= w[i]; --p) {
dp[p] = max(dp[p - w[i]] + v[i], dp[p]);
}
}
}
cout << *max_element(dp, dp + s + 1);
}| # | 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... | ||||
