Eurokod
InterviewTime limit1sMemory limit1024 MB
Given the president's ranking and each code's member vote count, print the codes by summed points in descending order, breaking ties by member votes.
- Level
Easy2 of 10
- Topics
- Sorting, Implementation
- Solved
- No attempts yet
Statement
This year, for the first time, the Eurokod is being held, an international competition in writing beautiful and readable code.
There are contestants, labeled from to . Each of them has written one code.
An association of computer scientists evaluates the codes. The association consists of a president and members. The president and the members award points in different ways.
President's points: The president ranks the codes from the most beautiful to the least beautiful. The first code receives points, and each following code receives one point less than the previous one.
Members' points: Each member votes for the code he considers the most beautiful. After all votes are cast, the codes are ranked in descending order of votes. The first code receives points, and each following code receives one point less than the previous one.
Total points: The total for each code is the sum of the points from the president and the points from the members.
Print the codes in descending order of total points. If codes have the same total, the code that received more points from the members is ranked higher.
Input
The first line contains an integer (), the number of contestants.
The second line contains integers (). The -th integer is the label of the code that the president ranked -th, from the most beautiful to the least beautiful. Every label from to appears exactly once.
The third line contains integers (). The -th integer is the number of votes that code received from the members. No two codes receive the same number of votes.
Output
Print lines with the ranking in descending order of total points. Each line has the form [rank]. Kod[label] ([number of points]). The label is written with two digits and a leading zero when needed. For example, if code 3 is first with 12 points, the first line is 1. Kod03 (12).
Hints
In the first example, Kod03 and Kod02 both have 3 points, but Kod03 received more votes from the members, so it is ranked higher.
In the second example, the president ranked Kod05 first, so it received points.