Submission #732306

#TimeUsernameProblemLanguageResultExecution timeMemory
732306Kak008723Knapsack (NOI18_knapsack)C++14
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> #define F first #define S second using namespace std; pair<int,int> p[10005]; int T,n,dp[10005]; int main(){ cin>>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<<=1){ p[num].F=j*v; p[num].S=j*w; num++; s-=j; } if(s){ p[num].F=s*v; p[num].S=s*w; num++; } } cin>>T; for(int i=1;i<=num;i++){ for(int j=T;j>=p[i].S;j--){ dp[j]=max(dp[j],dp[j-p[i].S]+p[i].F); } } 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...