제출 #970476

#제출 시각아이디문제언어결과실행 시간메모리
970476v_mateiKnapsack (NOI18_knapsack)C++17
73 / 100
1057 ms1384 KiB
#pragma GCC target ("avx,avx2") #include <iostream> #include <vector> #define ll long long #define ull unsigned long long #define pii std::pair<int, int> #define NMAX 100'007 #define SMAX 2007 int n, s; int v[NMAX], w[NMAX], k[NMAX]; int dp[SMAX]; void citire() { std::cin >> s >> n; for (int i = 1; i <= n; i++) std::cin >> v[i] >> w[i] >> k[i]; } int main() { citire(); for (int i = 1; i <= n; i++) { for (int j = s; j >= 0; j--) { for (int x = 0; j - w[i] * x >= 0 && x <= k[i]; x++) { dp[j] = std::max(dp[j], dp[j - x * w[i]] + x * v[i]); } } } std::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...