Last active
July 10, 2024 19:10
-
-
Save jkmartindale/cc94520295a9e5a40f81c2b0f99dde5d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sys import stdout, stdin | |
| songs = [] | |
| n_songs, select_n = map(int, stdin.readline().split()) | |
| n_songs = n_songs | |
| select_n = select_n | |
| for i in range(1, n_songs + 1): | |
| plays, title = stdin.readline().split() | |
| songs.append((int(plays) * i, title)) | |
| songs.sort(key=lambda song: song[0], reverse=True) | |
| for song in range(select_n): | |
| stdout.write(songs[song][1] + '\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment