제출 #1082891

#제출 시각아이디문제언어결과실행 시간메모리
1082891timmyli3481Knapsack (NOI18_knapsack)C++14
0 / 100
0 ms444 KiB
#include <bits/stdc++.h> // #include "stdc++.h" using namespace std; struct grass{ long long 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++){ long long 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(j-a[i].w*z>0){ break; } 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...