#P10223. [COCI 2023/2024 #3] Eurokod
[COCI 2023/2024 #3] Eurokod
Background
Translated from T1 "Eurokod" of COCI 2023/2024 Contest #3
Problem Description
Eurokod, the global competition for beautiful and highly readable code, is being held for the first time this year.
There are contestants in the competition, numbered in order from to . 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 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 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 (), the number of contestants.
The second line contains integers (). The -th integer is the code label that the leader ranked -th. They are given from highest beauty to lowest. It is guaranteed that each of to appears exactly once.
The third line contains integers (). The -th integer is the number of votes from the other members received by the -th code. It is guaranteed that no two codes received the same number of votes.
Output Format
Output 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 gets first place with a total of points, you should output 1. Kod03 (12) on the first line.
3
1 2 3
50 10 20
1. Kod01 (6)
2. Kod03 (3)
3. Kod02 (3)
5
5 2 4 1 3
4 5 2 1 3
1. Kod02 (9)
2. Kod05 (8)
3. Kod01 (6)
4. Kod04 (4)
5. Kod03 (3)
7
6 3 2 1 5 4 7
200 56 11 0 13 105 12
1. Kod06 (13)
2. Kod01 (11)
3. Kod02 (10)
4. Kod03 (8)
5. Kod05 (7)
6. Kod07 (4)
7. Kod04 (3)
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 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