| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1305926 | avs | Knapsack (NOI18_knapsack) | C++20 | 2 ms | 584 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x; cin >> x >> n;
vector<int> w(n), v(n), k(n), dp(x+1);
for (int i = 0; i < n; i++) cin >> v[i] >> w[i] >> k[i];
for (int i = 0; i < n; i++) {
int count = k[i];
for (int mul = 1; count > 0; mul <<= 1) {
int take = min(mul,count);
int tw = take * w[i];
int tv = take * v[i];
for (int j = x; j >= tw; j--) dp[j] = max(dp[j],dp[j-tw]+tv);
count -= take;
}
}
cout << dp.back();
}| # | 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... | ||||
