제출 #484274

#제출 시각아이디문제언어결과실행 시간메모리
484274maxshevKnapsack (NOI18_knapsack)C++14
0 / 100
0 ms204 KiB
#include <bits/stdc++.h> using namespace std; int main() { int s, n; cin >> s >> n; int dp[2001]; for (int i = 0; i <= s; i++) { dp[i] = -1; } dp[0] = 0; for (int i = 1; i <= n; i++) { int v, w, k; cin >> v >> w >> k; for (int x = s; x >= 0; x--) { if (dp[x] != -1) { dp[x + w] = dp[x] + v; } } } int res = 0; for (int i = 0; i <= s; i++) { res = max(res, dp[i]); } cout << res << '\n'; 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...