[Baekjoon 7579] App
A knapsack solution indexed by released memory to minimize app deactivation cost.
September 2, 2022
Deactivate apps to release at least the required memory while minimizing total cost. My implementation indexes DP by released memory and stores the minimum cost needed to obtain that amount.
dp[releasedMemory] = minimum deactivation cost
For each app, I updated memory indices from largest to smallest to avoid choosing the same app twice. When several choices released the same memory, I kept the cheapest.
I first reconsidered which quantity to optimize. Memory is the target and cost is what must be minimized, so I chose memory as the DP axis.
Problem: Baekjoon · Code: View on GitHub