173. Codeforces Top 10

Codeforces
IDCF10269173
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
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. 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 $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. ## 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 usernameThe third line of input consists of $n$ space-separated positive integers: each Codeforces user's rating, before any of the recent contestsThe 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. [samples]
**Definitions** Let $ n, k \in \mathbb{Z}^+ $ denote the number of users and contests, respectively. Let $ U = (u_1, u_2, \dots, u_n) $ be the tuple of usernames. Let $ R^{(0)} = (r_1^{(0)}, r_2^{(0)}, \dots, r_n^{(0)}) \in \mathbb{Z}^n $ be the initial ratings, with $ 1 \leq r_i^{(0)} < 4000 $. For each contest $ c \in \{1, \dots, k\} $, let $ \Delta^{(c)} = (\delta_1^{(c)}, \delta_2^{(c)}, \dots, \delta_n^{(c)}) \in \mathbb{Z}^n $ be the rating changes, where $ \delta_i^{(c)} $ is the change for user $ u_i $. **Constraints** 1. $ 1 \leq n \leq 10^5 $, $ 1 \leq k \leq 100 $ 2. $ 1 \leq r_i^{(0)} < 4000 $ for all $ i \in \{1, \dots, n\} $ 3. Each $ \delta_i^{(c)} \in \mathbb{Z} $, and is given in format $ +a $, $ -a $, or $ 0 $, with $ |a| < 4000 $ **Objective** For each contest $ c \in \{1, \dots, k\} $, compute the updated ratings: $$ r_i^{(c)} = r_i^{(c-1)} + \delta_i^{(c)} \quad \text{for all } i \in \{1, \dots, n\} $$ Then, output the top 10 users by descending rating; in case of ties, sort usernames in ascending lexicographical order. Output $ k $ lines, each containing the usernames of the top 10 users after contest $ c $, in order.
API Response (JSON)
{
  "problem": {
    "name": "173. Codeforces Top 10",
    "description": {
      "content": "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 ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269173"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There have been a lot of online Codeforces contests recently.\n\nOn Codeforces, each user is given a rating, which is a positive integer less than 4000. After each worldwide contest (which 10000+ users ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n, k \\in \\mathbb{Z}^+ $ denote the number of users and contests, respectively.  \nLet $ U = (u_1, u_2, \\dots, u_n) $ be the tuple of usernames.  \nLet $ R^{(0)} = (r_1^{(0)}, r_2...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments