407202: GYM102697 173 Codeforces Top 10

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

173. Codeforces Top 10time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
This problem is worth 45 points.

There have been a lot of online Codeforces contests recently.

On Codeforces, each user is given a rating, which is a positive integer less than 4000. After each worldwide contest (which 10000+ users compete in on average), everyone's rating value increases or decreases, depending on their performance in the competition. The higher your rating, the higher rank you will need to get a positive rating change. For example, if a user had a rating of 3700, their rating could decrease if they got 2nd place in a contest (out of 10000+ people). On the other hand, if a user was rated 900, their rating would increase even if they came in 5000th or 6000th place (out of 10000). As a result of this formula, the list of the top 10 users on Codeforces (based on rating) is constantly changing, although one person is usually at #1.

You're given a list of $$$n$$$ codeforces users, and their rating before any of the recent contests. You're then given a list of $$$k$$$ contests. Each contests contains the rating change for each contestant. Given this information, your task is to print out the list of the top 10 highest rated users after each contest.

Input

The first line of input consists of two space-separated integers $$$n$$$ and $$$k$$$: the number of Codeforces users, and the number of contests, respectively.

The second line of input consists of $$$n$$$ space-separated strings: each Codeforces user's username

The third line of input consists of $$$n$$$ space-separated positive integers: each Codeforces user's rating, before any of the recent contests

The next $$$k$$$ lines each contain info about a single contest. Each line will contain $$$n$$$ space-separated integers: the rating change for each user. Each user's index in the contest rating change list will be the same as their index in the original list of users. For example, if someone appeared first in the original list of users, their rating change would be first in each list of contest rating changes.

Each rating change will be given as +[amount], if the rating change was positive, -[amount], if the rating change was negative, and 0 otherwise. For example, +345, -172, and 0 are all valid rating changes.

Output

Output $$$k$$$ lines. On each line, output the names of the top 10 highest rated users after each contest. If two users have the same rating, sort them alphabetically by their username from lowest to highest.

ExamplesInput
12 6
MiFaFaOvO tourist Um_nik ecnerwala maroonrk 300iq Petr LHiC Benq TLE apiadu Radewoosh
3681 3669 3358 3119 3232 3317 3016 3229 3230 3374 3397 3104
0 +4 +135 +97 +18 0 +141 0 0 -151 0 -168
0 +60 0 +57 -7 0 +30 0 -17 0 0 +171
0 -192 -59 -13 +110 0 0 0 +7 0 0 -2
0 -132 +110 0 +78 0 0 0 +40 0 0 -115
0 +111 +23 +49 -10 0 0 0 +23 0 0 +65
0 +47 -40 +149 -12 0 +85 0 -57 0 -214 +102
Output
MiFaFaOvO tourist Um_nik apiadu 300iq maroonrk Benq LHiC TLE ecnerwala
tourist MiFaFaOvO Um_nik apiadu 300iq ecnerwala maroonrk LHiC TLE Benq
MiFaFaOvO tourist Um_nik apiadu maroonrk 300iq ecnerwala LHiC TLE Benq
MiFaFaOvO Um_nik maroonrk tourist apiadu 300iq Benq ecnerwala LHiC TLE
MiFaFaOvO Um_nik tourist maroonrk apiadu 300iq ecnerwala Benq LHiC TLE
MiFaFaOvO tourist Um_nik ecnerwala maroonrk 300iq Petr LHiC Benq TLE
Input
12 6
MiFaFaOvO tourist Um_nik ecnerwala maroonrk 300iq Petr LHiC Benq TLE apiadu Radewoosh
3681 3669 3358 3119 3232 3317 3016 3229 3230 3374 3397 3104
0 +12 +135 +97 +18 0 +141 0 0 -151 0 -168
0 +60 0 +57 -7 0 +30 0 -17 0 0 +171
0 -192 -59 -13 +110 0 0 0 +7 0 0 -2
0 -132 +110 0 +78 0 0 0 +40 0 0 -115
0 +111 +23 +49 -10 0 0 0 +23 0 0 +65
0 +47 -40 +149 -12 0 +85 0 -57 0 -214 +102
Output
MiFaFaOvO tourist Um_nik apiadu 300iq maroonrk Benq LHiC TLE ecnerwala
tourist MiFaFaOvO Um_nik apiadu 300iq ecnerwala maroonrk LHiC TLE Benq
MiFaFaOvO tourist Um_nik apiadu maroonrk 300iq ecnerwala LHiC TLE Benq
MiFaFaOvO Um_nik maroonrk tourist apiadu 300iq Benq ecnerwala LHiC TLE
MiFaFaOvO Um_nik tourist maroonrk apiadu 300iq ecnerwala Benq LHiC TLE
MiFaFaOvO tourist Um_nik ecnerwala maroonrk 300iq Petr LHiC Benq TLE

加入题单

算法标签: