제출 #856556

#제출 시각아이디문제언어결과실행 시간메모리
856556bad_ianKnapsack (NOI18_knapsack)C++17
17 / 100
2 ms1968 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { ll S, N; cin >> S >> N; vector<ll> vs(N + 1, 0); vector<ll> ws(N + 1, 0); vector<ll> ks(N + 1, 0); for(int i = 1; i <= N; i++){ ll V; ll W; ll K; cin >> V >> W >> K; vs[i] = V; ws[i] = W; ks[i] = K; } vector<vector<ll>> dp(S + 1, vector<ll>(N + 1, 0)); for(int s = 1; s <= S; s++){ for(int i = 1; i <= N; i++){ if(s >= ws[i]){ dp[s][i] = max(dp[s][i], dp[s-ws[i]][i-1] + vs[i]) ; } dp[s][i] = max(dp[s][i], dp[s][i-1]); } } cout << dp[S][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...