Submission #986115

#TimeUsernameProblemLanguageResultExecution timeMemory
986115shokal_kishanKnapsack (NOI18_knapsack)C++17
37 / 100
1016 ms600 KiB
#include<bits/stdc++.h> using namespace std; #define int long long void solve(){ int s,n; cin>>s>>n; vector<vector<int>>arr(n,vector<int>(3,0)); for(int i=0; i<n;i++){ int v,w,k; cin>>v>>w>>k; arr[i][0] = v ; arr[i][1] = w ; arr[i][2] = k ; } vector<int>dp(s+1,0); for(int i=0;i<n;i++){ for(int k =0;k<arr[i][2];k++){ for(int j=s;j>=arr[i][1];j--){ dp[j] = max( dp[j],dp[j-arr[i][1]]+arr[i][0]); } } } cout<<dp[s]<<endl; } int32_t main(){ int t=1; //cin>>t; while(t--) solve(); }
#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...