Editorial for MWC '15 #1 P1: Playlist Panic

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

Sorting the songs based on their length in ascending order, and greedily choosing songs until the total time runs out is sufficient to solve this problem. Edge cases occur when the time limit is 0 (a song of length 0 can still be listened to in this time!).

Time complexity: \mathcal{O}(N \log N), the time complexity of sorting N songs.


There are no comments at the moment.