| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1327755 | fly | Knapsack (NOI18_knapsack) | C++20 | 267 ms | 440 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int s, n;
cin >> s >> n;
vector<long long> bp(s+1);
int v, w, k;
for (int q = 0; q < n; q++) {
cin >> v >> w >> k;
for (int i = s; i >= 0; i--) {
for (int j = 1; j <= k; j++) {
int nw = i + j*w;
if (nw > s) break;
if (bp[i]+v*j > bp[nw]) {
bp[nw] = bp[i] + v*j;
} else {
break;
}
}
}
}
long long answer = 0;
for (int i = 0; i <= s; i++) {
answer = max(answer, bp[i]);
}
cout << answer;
}| # | 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... | ||||
