Krillboard Hot 100
Krillin the Krill is a data-scientist working at Big Krill and wants to study the Krillboard Hot 100, which charts the popularity of songs.
Instead of traditional rankings, the Krillboard measures popularity using a Krill Score.
In this system, a lower score is better (a score of 1 is vastly more popular than a score of 100). A song's Krill Score is completely independent of other songs, meaning one song's score changing does not force another song's score to change.
Through Krillin's deft ML skills, he has determined that each week, the 'th song has:
- A probability of
% to get more popular (its Krill Score decreases by 1).
- A probability of
% to get less popular (its Krill Score increases by 1).
- Otherwise, its score does not change.
For each song, calculate its expected Krill Score after exactly weeks. The predicted Krillboard chart is formed by sorting songs in increasing order of their expected score (best scores first).
If two songs have the exact same expected score, the song with the lexicographically smaller title comes first (e.g., "apple" beats "zebra").
Expected scores do not need to be whole numbers. They may be fractional or even negative.
Input
The first line begins with two integers and
, the number of songs and the number of weeks.
The next lines each contain a string
and three integers
:
is the title of the song. It consists only of lowercase English letters and has length from
to
. It is guaranteed that all song titles are unique;
is the current Krill Score of the song;
is the probability that the song gets more popular in one week;
is the probability that the song gets less popular in one week.
It is guaranteed that .
It is also guaranteed that the initial scores
happen to form a permutation of the integers from
to
.
Output
Output song titles separated by spaces on a single line in the order of the predicted Krillboard chart.
Example
Input 1
3 10
lovetakesmiles 1 10 50
taxes 2 80 0
cobra 3 20 20
Output 1
taxes cobra lovetakesmiles
lovetakesmilesstarts with a score of. In the first week, it has a
chance to improve (score becomes
), a
chance to worsen (score becomes
), and a
chance to stay the same (score remains
). Its expected score after
week is
. Continuing this process, its expected score after
weeks evaluates to exactly
.
taxesstarts with a score of. In the first week, it has an
chance to improve (score becomes
), a
chance to worsen (score becomes
), and a
chance to stay the same (score remains
). Its expected score after
week is
. After
weeks, its expected score evaluates to
.
cobrastarts with a score of. Its probabilities of improving and worsening cancel each other out exactly, so its expected score after
weeks remains
.
Sorting them by expected score in increasing order gives the final chart order:
taxes, cobra, lovetakesmiles.
Input 2
5 1000
krillofyou 1 0 100
krillinglights 2 50 50
krillsummer 3 100 0
krillofafeather 4 30 20
krillineed 5 10 10
Output 2
krillsummer krillofafeather krillinglights krillineed krillofyou
Comments
i love dicts
thanks this was really helpfuL: Your output (clipped) uhiclhquegdf hrqcxnpzvole zssobyvdhmh nlfugqpqyo omholxel iulbvsjr dzgkwcy yfgjbhsughp gkeiczt bvgxbyj okglz uapbyqc eiqssfpvgsgzbx olfidvndlbupxn seeae kpbqtyyvw xgquyim yqdebbskfa lzhfkoxjfpkv gnjtftfvbpgp lyejaverbpnf ftevqjdvqx zyxmjd etpigu jarcuvltuiwks isycmdt habjm sdjylcoos aszfaznlqoj iybixbagwa oyljvyofudotskt pxpqrfsspskdvef cgwmknexlxbyr lcgluzihqz lsrokvhljjtease hbdfvfrlse bqlptg sqsbzmpjdmvpp nwwyrca fsfsgihvntgo kmxbroa kancszad uaobbcgot dqbpy jukrv rdmacvrnp svjkzvlsyvz rxseyrkxld ekvczojhuazxxmm fkesbuuoxne qklwviyttemq uxpikh vohghixbhzap ghqyip kvwklw fljzgsmpr klvwbqyjsuecppw jxocpfwjrsn ksbaah pobxbkahln antpiuz kwynattvvv ymjuesuvwoabh dqpjstyonnmfn aazojevruqpls tvpjinmfaurveeu xezpnfjxd buvwvryguhjnh flaqldvteplh jzqvoaju oenrdejdz xjysh fgcuuvzbl jckeviswuor iwadltvtkdg lwdkrjfajww zsulfcjw khuzuwhh tehfujuodgo vrhbytmms cyduzirjw flqvadekqkb fbynord kukzsbpv uyvzr sofxrufflfr jhszypiscpuvwbs ricrcufslpqpdi tpguizzxqva kpltxeumbgginx mlkabrpadjfih qlkrzt ssyfroqujcol lnkrujc jxgqa ldnvfd dmggnyoqfhdj wfypikymebkjoui xgxajqggxkyzkx uyccxlifhf