제출 #985664

#제출 시각아이디문제언어결과실행 시간메모리
985664vjudge1Knapsack (NOI18_knapsack)C++17
17 / 100
3 ms348 KiB
#include <bits/stdc++.h> using i64 = long long; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int S, N; std::cin >> S >> N; std::vector<int> dp(1 + S); for (int i = 0; i < N; i++) { int v, w, k; std::cin >> v >> w >> k; for (int c = 1; c <= k; c++) { for (int j = S - w * c; j >= 0; j--) { dp[j + w * c] = std::max(dp[j + w * c], dp[j] + v * c); } } } std::cout << dp[S] << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...