Submission #1048749

#TimeUsernameProblemLanguageResultExecution timeMemory
1048749tamir1Knapsack (NOI18_knapsack)C++17
37 / 100
1048 ms2492 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; ll n,S,i,j,l,res,dp[2005],s[100001],w[100001],k[100001]; int main(){ cin >> S >> n; for(i=1;i<=n;i++){ cin >> s[i] >> w[i] >> k[i]; } for(i=1;i<=n;i++){ for(j=1;j<=k[i];j++){ for(l=S;l>=w[i];l--){ dp[l]=max(dp[l],dp[l-w[i]]+s[i]); } } } for(i=0;i<=S;i++) res=max(res,dp[i]); cout << res; }
#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...