제출 #1067472

#제출 시각아이디문제언어결과실행 시간메모리
1067472rohanjhaKnapsack (NOI18_knapsack)C++14
17 / 100
3 ms348 KiB
#include<iostream> #include<vector> using namespace std; int main(){ int s, n; cin>>s>>n; vector<vector<int> > items; for(int i=0; i<n; i++){ int v, w, k; cin>>v>>w>>k; vector<int> item; item.push_back(v); item.push_back(w); item.push_back(k); items.push_back(item); } vector<int> dp(s+1, 0); for(int i=0; i<n; i++){ for(int j=items[i][2]; j>0; j--){ for(int k=s; k>=items[i][1]*j; k--){ dp[k]=max(dp[k], dp[k-items[i][1]*j]+items[i][0]*j); } } } cout<<dp[s]<<endl; 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...