제출 #548992

#제출 시각아이디문제언어결과실행 시간메모리
548992alexz1205Knapsack (NOI18_knapsack)C++17
37 / 100
1092 ms212 KiB
#include <iostream> using namespace std; int main() { int s, n; cin >> s >> n; long long int data[n][3], dp[s+1], next[s+1]; for (int x = 0; x < n; x ++){ cin >> data[x][0] >> data[x][1] >> data[x][2]; } for (int x = 0; x <= s; x ++){ dp[x] = next[x] = 0; } for (int a = 0; a < n; a ++){ int c = data[a][0], w = data[a][1], k = data[a][2]; for (int b = 0; b < k; b ++){ for (int x = w; x <= s; x ++){ next[x] = max(max(dp[x], dp[x-w] + c), next[x-1]); } for (int x = w; x <= s; x ++){ dp[x] = next[x]; } } } cout << dp[s] << endl; 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...