P10223 [COCI 2023/2024 #3] Eurokod

Background

**Translated from T1 "[Eurokod](https://hsin.hr/coci/archive/2023_2024/contest3_tasks.pdf)" of [COCI 2023/2024 Contest #3](https://hsin.hr/coci/archive/2023_2024)**

Description

Eurokod, the global competition for beautiful and highly readable code, is being held for the first time this year. There are $n$ contestants in the competition, numbered in order from $1$ to $n$. Each contestant has already written a piece of code. Their code will be evaluated by a group of computer scientists. This group is divided into the leader and the other members. The leader will give scores using one method, and the other members will give scores using another method. **Leader scoring:** The leader sorts the code from most beautiful to least beautiful according to his own opinion. The most beautiful code gets $n$ points, and each next code gets one point less than the previous one. **Other members scoring:** Each other member votes for the code they think is the most beautiful. After all other members have voted, all code is sorted by the number of votes from highest to lowest. The code with the most votes gets $n$ points, and each next code gets one point less than the previous one. **Total score:** The total score of a piece of code is the sum of the leader score and the other members score. Your task is to output the code labels in descending order of total score. If two pieces of code have the same total score, the one with the higher other members score comes first.

Input Format

The first line contains an integer $n$ ($1 \le n \le 50$), the number of contestants. The second line contains $n$ integers $a_i$ ($1 \le a_i \le n$). The $i$-th integer is the code label that the leader ranked $i$-th. They are given from highest beauty to lowest. It is guaranteed that each of $1$ to $n$ appears exactly once. The third line contains $n$ integers $b_i$ ($0 \le b_i \le 200$). The $i$-th integer is the number of votes from the other members received by the $i$-th code. It is guaranteed that no two codes received the same number of votes.

Output Format

Output $n$ lines, printing code labels in descending order of score. Each line should follow the format `[rank]. Kod[label] ([number of points])`. Here, `[rank]` is the rank of the code, `[label]` is the two-digit code label with leading zeros, and `[number of points]` is the total score of the code. For example, if code $3$ gets first place with a total of $12$ points, you should output `1. Kod03 (12)` on the first line.

Explanation/Hint

### Sample Explanation 1 Kod03 and Kod02 have the same score, but Kod03 got a higher score from the other members, so Kod03 is ranked earlier. ### Sample Explanation 2 The leader gave Kod05 the highest rank, so it gets $n=5$ points. ### Subtasks | Subtask | Points | Constraints | |:--:|:--:|:--:| | 1 | 17 | For each code, the number of votes from the other members is numerically the same as the other members score. Also, no two codes have the same total score. | | 2 | 19 | No two codes have the same total score. | | 3 | 14 | No special constraints. | Translated by ChatGPT 5