Submission #1020937

#TimeUsernameProblemLanguageResultExecution timeMemory
1020937urejgiKnapsack (NOI18_knapsack)C++17
73 / 100
1052 ms4040 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main(){ int s, n; cin >> s >> n; vector<int> v(n), w(n), c(n); for (int i = 0; i < n; ++i) { cin >> v[i] >> w[i] >> c[i]; } vector<int> dp(s + 1, 0); for (int i = 0; i < n; ++i) { for (int j = s; j >= 0; --j) { for (int l = 1; l <= c[i] && l*w[i] <= j; ++l) { dp[j] = max(dp[j], dp[j - l * w[i]] + l * v[i]); } } } cout << dp[s] << '\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...