Submission #679388

#TimeUsernameProblemLanguageResultExecution timeMemory
679388nicolexxuuKnapsack (NOI18_knapsack)C++14
17 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; int S, N, items[100000][3]; int dp[2001]; int main() { cin >> S >> N; for(int i = 0; i < N; i++) { // cin >> items[i][0] >> items[i][1] >> items[i][2]; int V, W, K; cin >> V >> W >> K; for(int i = 1; i <= K && i*W <= S; i++) dp[S] = max(dp[S], dp[S-W*i] + V*i); for(int s = S-1; s >= 1; s--) { if(W * K <= s) dp[s] = max(dp[s], dp[s-W*K] + V*K); } } cout << dp[S] << endl; }
#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...