제출 #986129

#제출 시각아이디문제언어결과실행 시간메모리
986129shokal_kishanKnapsack (NOI18_knapsack)C++17
73 / 100
1036 ms7164 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++){ if((k+1)*arr[i][1]>s) break; 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...