| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1330002 | pucam20102 | Knapsack (NOI18_knapsack) | C++20 | 1 ms | 344 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int N, S;
cin >> N >> S;
vector<int> dp(S + 1, 0);
for(int i = 0; i < N; i++) {
int Vi, Wi, Ki;
cin >> Vi >> Wi >> Ki;
for(int power = 1; Ki > 0; power <<= 1) {
int take = min(power, Ki);
int weight = take * Wi;
int value = take * Vi;
for(int j = S; j >= weight; j--) {
dp[j] = max(dp[j], dp[j - weight] + value);
}
Ki -= take;
}
}
cout << dp[S] << "\n";
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... | ||||
