Editorial for COCI '23 Contest 3 #1 Eurokod
Submitting an official solution before solving the problem yourself is a bannable offence.
To solve this task we will create two arrays, one in which we will store the total number of points of
the -th competitor, and the other in which we will store the number of points that the members of the
association have assigned to the
-th competitor.
Let's look at the president's scoring. If the -th place of his ranking is marked with
, then the
-th
competitor gets
points, where
is the total number of competitors.
Let's look at the scoring of the members of the association. In the first subtask, it is true that for each
code the number of votes of the members for that code is equal to the number of points they assigned to
it. In that case, we add the number of votes of the members for his code to the total number of points of
the -th competitor. Let's move on to the general case, when it is not true that the votes and points of the
members of the association match. Let's create an array of pairs
, where
is the number of votes of
the members of the association for the
-th code. Sort that array in ascending order by the number of
votes. Now we will assign points to the competitors using that array. Let the pair
be at the
-th
place. Then the
-th code is assigned
points by the members of the association.
For example, let the votes of the members of the association be 50 10 20
, the array of pairs before sorting
is (50, 1) (10, 2) (20, 3)
, and after sorting (10, 2) (20, 3) (50, 1)
. Then the second code is
assigned point, the third
points, and the first
points.
Let's now create an array where each element consists of three numbers, the first number is the total
number of points of the -th competitor, the second number is the number of points that the
-th competitor
received from the members of the association, and the third number is the code label (i.e. the number
).
Sort that array in descending order by the first number, and if the first numbers are equal, then in descending order by the second number.
The sorted array is also the final ranking of competitors. It only remains to print the ranking of competitors in the appropriate format.
Comments