Submission #1020934

#TimeUsernameProblemLanguageResultExecution timeMemory
1020934urejgiKnapsack (NOI18_knapsack)C++17
12 / 100
1 ms348 KiB
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #include <bits/stdc++.h> #define int long long using namespace std; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int s, n; cin >> s >> n; vector<int> c(n), w(n), v(n), dp(s+1); for(int i = 0; i < n; i++){ cin >> v[i] >> w[i] >> c[i]; } for(int i = 0; i <= n; ++i){ for(int j = s; j >= 0; --j){ for(int l = 1; l <= c[i] && l*w[i] <= j; ++l){ dp[j] = max(dp[j], dp[j - l*w[i]] + l*v[i]); } } } cout << dp[s]; 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...