Submission #1099193

#TimeUsernameProblemLanguageResultExecution timeMemory
1099193coin_Knapsack (NOI18_knapsack)C++14
37 / 100
1063 ms66204 KiB
#include <bits/stdc++.h> #define int long long #define endl '\n' #define fi first #define se second using namespace std; signed main(){ ios_base::sync_with_stdio(0); cin.tie(nullptr); int s, n; cin >> s >> n; vector<pair<int, int>> stuff; for (int i = 0; i < n; i++){ int v, w, k; cin >> v >> w >> k; for (int j = 0; j < k; j++){ stuff.push_back({v, w}); } } int num = stuff.size(); vector<int> dp(s+1, 0); for (int i = 0; i < num; i++){ for (int j = s; j >= stuff[i].se; j--){ dp[j] = max(dp[j], dp[j-stuff[i].se] + stuff[i].fi); } } cout << dp[s]; }
#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...