Submission #856555

#TimeUsernameProblemLanguageResultExecution timeMemory
856555bob123Knapsack (NOI18_knapsack)C++17
0 / 100
2 ms1884 KiB
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { ll s,n; cin>>s>>n; vector<ll>ws; vector<ll>vs; for(ll i=0;i<n;i++){ ll v,w,k; cin>>v>>w>>k; ws.push_back(w); vs.push_back(v); } vector<vector<ll>>dp(s+1,vector<ll>(n+1,0)); for(ll j=1;j<=s;j++){ for(int i=1;i<=n;i++){ if(j>=ws[i]){ dp[j][i]=max(dp[j][i],dp[j-ws[i]][i-1]+vs[i]); } dp[j][i]=max(dp[j][i],dp[j][i-1]); } } cout<<dp[s][n]; return 0; }
#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...