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