Submission #930263

#TimeUsernameProblemLanguageResultExecution timeMemory
930263naghsKnapsack (NOI18_knapsack)C++17
73 / 100
1094 ms2908 KiB
#include <iostream> #include <vector> using namespace std; int main() { int s, n; cin >> s >> n; vector<int> v(n), w(n), q(n); for(int i = 0; i < n; i++) cin >> v[i] >> w[i] >> q[i]; vector<int> dp(s + 1, 0); for(int i = 0; i < n; i++) for(int j = s; j >= w[i]; j--) for(int k = 0; k <= min(j / w[i], q[i]); k++) dp[j] = max(dp[j], dp[j - k * w[i]] + k * v[i]); cout << dp[s]; 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...