Submission #701977

#TimeUsernameProblemLanguageResultExecution timeMemory
701977PenguinsAreCuteKnapsack (NOI18_knapsack)C++17
73 / 100
437 ms262144 KiB
#include <bits/stdc++.h> using namespace std; typedef int ll; ll dp[100001][2001]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); ll N, W; cin >> W >> N; ll w[N], v[N], K[N]; for(ll i = 0; i < N; i++) { cin >> v[i] >> w[i] >> K[i]; } for(ll i = 1; i <= N; i++) { for(ll j = 1; j <= W; j++) { for(ll k = 0; k * w[i - 1] <= j && k <= K[i - 1]; k++) {dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i-1] * k] + v[i-1] * k);} } } cout << dp[N][W]; }
#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...