제출 #1188307

#제출 시각아이디문제언어결과실행 시간메모리
1188307alwaus424Knapsack (NOI18_knapsack)C++20
17 / 100
1095 ms328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int S, N; cin >> S >> N; vector<ll> dp(S + 1, 0); for (int i = 0; i < N; i++) { int v, w, k; cin >> v >> w >> k; for (int cnt = 1; cnt <= k; cnt++) { for (int j = S; j >= w; j--) { if (j >= cnt * w) dp[j] = max(dp[j], dp[j - cnt * w] + 1LL * cnt * v); } } } cout << *max_element(dp.begin(), dp.end()) << "\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...