Submission #754774

#TimeUsernameProblemLanguageResultExecution timeMemory
754774asdasdqwerKnapsack (NOI18_knapsack)C++14
37 / 100
1061 ms212 KiB
#include <bits/stdc++.h> using namespace std; int main() { int s, n; cin >> s >> n; vector<int> dp(s+1, 0); for (int i = 0; i < n; i++) { int 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...