Skip to content

Instantly share code, notes, and snippets.

@jkmartindale
Last active July 10, 2024 19:10
Show Gist options
  • Save jkmartindale/cc94520295a9e5a40f81c2b0f99dde5d to your computer and use it in GitHub Desktop.
Save jkmartindale/cc94520295a9e5a40f81c2b0f99dde5d to your computer and use it in GitHub Desktop.
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