Submission #732732

#TimeUsernameProblemLanguageResultExecution timeMemory
732732Kak008723Knapsack (NOI18_knapsack)C++14
37 / 100
2 ms596 KiB
#include<bits/stdc++.h> using namespace std; int V[10000],W[10000]; int T,n,dp[100005]; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>T>>n; int num=1; for(int i=1;i<=n;i++){ int v,w,s; cin>>v>>w>>s; for(int j=1;j<=s;j++){ V[num]=v; W[num]=w; num++; } } /*cout<<"\n"; for(int i=1;i<num;i++){ cout<<W[i]<<' '; }*/ for(int i=1;i<=num;i++){ for(int j=T;j-W[i]>=0;j--){ dp[j]=max(dp[j],dp[j-W[i]]+V[i]); } } cout<<dp[T]; }
#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...