| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1347748 | dkasabovn | Knapsack (NOI18_knapsack) | C++20 | 1094 ms | 344 KiB |
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int s, n;
cin >> s >> n;
vector<int> values(n);
vector<int> weights(n);
vector<int> amounts(n);
for (int i = 0; i < n; i++) {
cin >> values[i];
cin >> weights[i];
cin >> amounts[i];
}
vector<int> dp(s+1, 0);
dp[0] = 0;
// 2 4 6
// 3 5 7
for (int i = 0; i < n; i++) {
auto value = values[i];
auto weight = weights[i];
for (int j = s; j >= 0; j--) {
auto amount = amounts[i];
while (amount > 0) {
if (j >= weight * amount) {
dp[j] = max(dp[j], dp[j - amount * weight] + value * amount);
}
amount--;
}
}
}
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... | ||||
