Pregunta de entrevista de Spotnana

Question related to priority queue and DP