Submission #591945

#TimeUsernameProblemLanguageResultExecution timeMemory
591945multifanblinksKnapsack (NOI18_knapsack)C++14
73 / 100
1077 ms3916 KiB
#include <iostream> using namespace std; typedef long long ll; const unsigned MAX = 100003, MAX_2 = 2003; int s, n; ll v[MAX], w[MAX], k[MAX], sack[MAX_2]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> s >> n; for (int i = 0; i < n; i++) cin >> v[i] >> w[i] >> k[i]; for (int i = 0; i <= s; i++) sack[i] = 0; for (int i = 0; i < n; i++) for (int j = s; j >= 0; j--) for (int q = 1; q * w[i] <= j && q <= k[i]; q++) sack[j] = max(sack[j], sack[j - q * w[i]] + q * v[i]); cout << sack[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...