제출 #930264

#제출 시각아이디문제언어결과실행 시간메모리
930264naghsKnapsack (NOI18_knapsack)C++17
73 / 100
1049 ms1628 KiB
#include <iostream> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); int s, n; cin >> s >> n; vector<int> v(n), w(n), q(n); for(int i = 0; i < n; i++) cin >> v[i] >> w[i] >> q[i]; vector<int> dp(s + 1, 0); for(int i = 0; i < n; i++) for(int j = s; j >= w[i]; j--) for(int k = 0; k <= min(j / w[i], q[i]); k++) dp[j] = max(dp[j], dp[j - k * w[i]] + k * v[i]); cout << dp[s]; 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...