Submission #1082889

#TimeUsernameProblemLanguageResultExecution timeMemory
1082889timmyli3481Knapsack (NOI18_knapsack)C++14
37 / 100
1045 ms444 KiB
#include <bits/stdc++.h> // #include "stdc++.h" using namespace std; struct grass{ int v,w,c; }; long long dp[10000001]; grass a[10001]; int main(){ int T,m; cin>>T>>m; for(int i=1;i<=m;i++){ int temp1,temp2,temp3; cin>>temp1>>temp2>>temp3; a[i]={temp1,temp2,temp3}; } for(int i=1;i<=m;i++){ for(int j=T;j>=a[i].w;j--){ for(int z=0;z<=a[i].c;z++){ if (a[i].w*z<=j){ dp[j]=max(dp[j],dp[j-a[i].w*z]+a[i].v*z); } } } } 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...