Submission #488659

#TimeUsernameProblemLanguageResultExecution timeMemory
488659ZybgKnapsack (NOI18_knapsack)C++11
73 / 100
431 ms3708 KiB
#include <bits/stdc++.h> using namespace std; int s,n,v[100010],w[100010],k[100010]; int dp[110][2010]; int main(){ cin >> s >> n; for(int i=1;i<=n;i++){ cin >> v[i] >> w[i] >> k[i]; } for(int i=1;i<=n;i++){ for(int j=s;j>=0;j--){ int t = 0; while(j+t*w[i]<=s && t<=k[i]){ dp[i][j] = max(dp[i-1][j+t*w[i]]+t*v[i],dp[i][j]); t++; } } } int ans = 0; for(int j=0;j<=s;j++){ ans=max(ans,dp[n][j]); } cout << ans; 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...