Submission #726586

#TimeUsernameProblemLanguageResultExecution timeMemory
726586Azther0zKnapsack (NOI18_knapsack)C++11
37 / 100
1067 ms212 KiB
#include <bits/stdc++.h> using namespace std; struct ITEM { int value,weight,copy; }; int main() { int s,n; cin >> s >> n; ITEM item[n]; for(int i=0;i<n;i++) cin >> item[i].value >> item[i].weight >> item[i].copy; long long dp[s+1]={},result=0; for(int i=0;i<n;i++) { while(item[i].copy--) { for(int j=s;j>=item[i].weight;j--) { dp[j]=max(dp[j],dp[j-item[i].weight]+item[i].value); result=max(result,dp[j]); } } } cout << result; }
#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...