Who is the final winner?
InterviewTime limit1sMemory limit128 MB
Each of N players holds M cards; every round all players play their largest remaining card and whoever plays the highest value scores a point. Report the player(s) with the most points.
- Level
Easy3 of 10
- Topics
- Sorting, Simulation, Implementation, Array
- Solved
- No attempts yet
Problem
After many tournament rounds, players are left. Each player holds cards, and every card has a number written on it.
On each turn every player puts down the largest card still in their hand, and the player who put down the largest number gains 1 point. Several players can put down that largest number, and in that case each of them gains 1 point. The cards used on a turn are discarded.
After turns, which player has gained the most points?
Input
The first line has the number of players and the number of cards each player holds , separated by a space. (, )
Each of the next lines has the numbers written on one player's cards. Writing a card number as , . The numbers on a line come in no fixed order.
Output
Print the number of the final winner. Players are numbered 1 to in the order they are given.
If several players have gained the most points, print their numbers in ascending order on one line, separated by a single space.