#P8342. [COCI 2021/2022 #6] Med
[COCI 2021/2022 #6] Med
Problem Description
Today is the last round of the Open Competition. People know that the two contests use the same scoring system. More precisely, both contests have rounds, and in each round the score is between and points. The scores from all rounds are added up to form the total score used for the final ranking.
After all six rounds finish, contestants are ranked by total score. If two contestants have the same score, then the one with the lexicographically smaller name is ranked before the one with the lexicographically larger name. No two contestants have the same name.
The beekeepers are very impatient, and they want to know their final ranking in advance.
Each beekeeper wants to know the best and worst position they can possibly end up with in the final ranking. As programmers for the contest, they ask you to tell them what rank they could occupy after the sixth round.
Input Format
The first line contains a positive integer , the number of beekeepers.
The next lines each contain a beekeeper name and numbers , representing the score of the -th beekeeper in the first rounds.
Output Format
Output lines.
On the -th line, output the best possible rank and the worst possible rank for the -th beekeeper.
3
pavel 120 200 300 400 500
keko 150 400 300 200 100
bartol 470 120 90 93 189
1 2
1 3
2 3
2
ante 275 275 275 275 275
mate 25 100 175 250 325
1 1
2 2
Hint
Sample 2: so far, has points and has points. If gets points in the last round and gets points, then the final result is a tie and they both have points. However, since the ranking uses lexicographical order, is smaller than , so will still be ranked ahead.
Constraints:
For of the testdata: .
For of the testdata: , (it is guaranteed that everyone’s name is unique), .
The score setting of this problem is the same as COCI 2021-2022#6, with a full score of points.
Translated by ChatGPT 5