Submission #718599

#TimeUsernameProblemLanguageResultExecution timeMemory
718599izanbfKnapsack (NOI18_knapsack)C++14
73 / 100
1064 ms1132 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); 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 s = S; s >= 0; --s) { for (int j = 1; j*w <= s and j <= k; ++j) { dp[s] = max(dp[s], dp[s-j*w]+j*v); } } } cout << dp[S] << endl; }
#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...