Submission #1086118

#TimeUsernameProblemLanguageResultExecution timeMemory
1086118lukasuliashviliKnapsack (NOI18_knapsack)C++17
0 / 100
1 ms860 KiB
#include <bits/stdc++.h> using namespace std; const int N=2005; int v[N],w[N],dp[N][N],k[N]; int main() { int s,n; cin>>s>>n; for(int i=1; i<=n; i++){ cin>>v[i]>>w[i]>>k[i]; /// v[i]_value w[i]_weight } for(int i=0; i<=n; i++){/// i_ramdeni itemi shedis j_ra masa eteva for(int j=0; j<=s; j++){ dp[i][j]=dp[i-1][j]; /// tu nivti ar aviget; for(int count=1; count<=k[i]; count++){ if(j-count*w[i]<0) break; dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]*count]+v[i]); } } } cout<<dp[n][s]<<endl; }
#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...