Submission #720414

#TimeUsernameProblemLanguageResultExecution timeMemory
720414mseebacherKnapsack (NOI18_knapsack)C++17
0 / 100
2 ms324 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct Produkt{ ll v,w,k; }; int main(){ ios::sync_with_stdio(0); cin.tie(nullptr); cout << fixed << setprecision(8); int s,n; cin >> s >> n; vector<Produkt> p(n); for(int i = 0;i<n;i++){ cin >> p[i].v >> p[i].w >> p[i].k; } vector<ll> dp(n,0); for(int i = 0;i<n;i++){ for(int j = p[i].w;j<=s;j++){ dp[j] = max(dp[j],dp[j-p[i].w] + p[i].v); } } ll ans = 0; for(int i = 0;i<n;i++){ ans = max(ans,dp[i]); } cout << ans; }
#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...