제출 #726585

#제출 시각아이디문제언어결과실행 시간메모리
726585Azther0zKnapsack (NOI18_knapsack)C++11
37 / 100
1082 ms412 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; int 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...