Submission #712681

#TimeUsernameProblemLanguageResultExecution timeMemory
712681cfjasonKnapsack (NOI18_knapsack)C++17
37 / 100
1077 ms340 KiB
#include <bits/stdc++.h> #include <climits> #include <vector> using namespace std; int main(int argc, char *argv[]) { int s, n; cin >> s >> n; vector<int> dp(s + 1, INT_MIN); dp[0] = 0; int result = 0; for (int i = 0; i < n; i++) { int v, w, k; cin >> v >> w >> k; for (int q = s; q >= w; q--) { for (int j = 1; j <= k; j++) { if (q - j * w < 0) continue; dp[q] = max(dp[q], dp[q - j * w] + j * v); } result = max(result, dp[q]); } } cout << result << endl; 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...