Submission #1010074

#TimeUsernameProblemLanguageResultExecution timeMemory
1010074MuhammetKnapsack (NOI18_knapsack)C++17
73 / 100
240 ms262144 KiB
#include <bits/stdc++.h> using namespace std; #define N 300005 #define ll long long int #define sz(x) (int)x.size() #define ff first #define ss second ll T, n, s, dp[N]; vector <pair<ll,ll>> v1; int main(){ cin >> s >> n; for(int i = 1; i <= n; i++){ ll v, w, k; cin >> v >> w >> k; for(int j = 1; j <= min(s/w,k); j++){ v1.push_back({v,w}); } } for(auto i : v1){ int v = i.ff, w = i.ss; for(int j = s; j >= 0; j--){ if(dp[j] != 0 or j == 0){ dp[j + w] = max(dp[j] + v, dp[j + w]); } } } ll mx = 0; for(int i = 1; i <= s; i++){ mx = max(dp[i],mx); } cout << mx; 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...