Submission #1016882

#TimeUsernameProblemLanguageResultExecution timeMemory
1016882thinknoexitKnapsack (NOI18_knapsack)C++17
73 / 100
1083 ms1428 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int v[100100], w[100100], k[100100]; int dp[2020]; int main() { cin.tie(nullptr)->sync_with_stdio(false); int s, n; cin >> s >> n; for (int i = 1;i <= n;i++) { cin >> v[i] >> w[i] >> k[i]; k[i] = min(k[i], s / w[i]); while (k[i]--) { for (int j = 2000;j >= w[i];j--) { dp[j] = max(dp[j], dp[j - w[i]] + v[i]); } } } cout << (*max_element(dp, dp + s + 1)); 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...