Submission #754776

#TimeUsernameProblemLanguageResultExecution timeMemory
754776asdasdqwerKnapsack (NOI18_knapsack)C++14
37 / 100
1084 ms252 KiB
#include <bits/stdc++.h> using namespace std; int main() { int s, n; cin >> s >> n; vector<int64_t> dp(s+1, 0); for (int i = 0; i < n; i++) { int64_t v, w, k; cin >> v >> w >> k; for (int j = 0; j < k; j++) { for (int r = s; r >= w; r--) { if (dp.at(r) < dp.at(r-w) + v) { dp[r] = dp.at(r-w) + v; } } } } cout << dp.at(s) << "\n"; }
#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...