| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1353716 | vjudge1 | Knapsack (NOI18_knapsack) | C++20 | 1097 ms | 66188 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
signed main() {
int s, n;
cin >> s >> n;
vector<pii> item;
for (int i = 0; i < n; i++) {
int v, w, k;
cin >> v >> w >> k;
int r = 0;
for (int j = 1; j * 2 <= k; j *= 2) {
r += j;
item.push_back(make_pair(j * w, j * v));
}
item.push_back(make_pair((k - r) * w, (k - r) * v));
}
vector<int> dp(s + 1);
for (auto& [w, v] : item) {
for (int i = s; i >= 0; i--) {
dp[i] = max(dp[i], i - w >= 0 ? dp[i - w] + v : 0);
}
}
cout << dp[s] << " ";
}| # | 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... | ||||
