Company: MediaNet_21july
Difficulty: medium
Vanish the Gems Problem Description A chest in front of you holds a collection of gems, and you quickly discover each one carries a curse that inflicts misfortune once it activates. Your goal is to keep the total misfortune you absorb as low as possible. You are able to smash any single gem in exactly 1 second, and you may smash gems in whatever order suits you. You are given a 2D array A, where the i-th gem needs A[i][0] seconds to finish delivering A[i][1] units of misfortune. Only one gem may be actively delivering misfortune to you at any given moment, though you choose the order in which gems get to deliver theirs. Once a gem begins delivering its misfortune it can no longer be smashed, and it disappears on its own the instant it has delivered all A[i][1] units. However, while one gem is delivering misfortune to you, you are free to smash any other gem still sitting in the chest. There is no gap between one gem finishing its delivery and the next one starting: the moment a gem is