Winning ICPC
Time limit2sMemory limit512 MB
Count how many problems each team fully solved (S = T), then report the team with the most solves, breaking ties by smallest index.
- Level
Easy1 of 10
- Topics
- Array, Implementation
- Solved
- No attempts yet
Problem
There are teams numbered to and problems numbered to . Problem has test cases. Every team submitted exactly one solution to every problem, and team passed test cases on problem .
A team is counted as having solved problem only when it passed all of its test cases, that is when . The winning team is the team that solved the largest number of problems. If two or more teams tie for the largest number, the winner is the one with the smallest index among them.
Determine the index of the winning team.
Input
The first line contains two integers and , separated by a space (), denoting the number of teams and the number of problems.
The second line contains integers , separated by spaces (), denoting the number of test cases of each problem.
Each of the following lines contains integers. The -th integer on the -th of these lines is (), the number of test cases passed by team on problem .
Output
Print the index of the winning team on one line.
Hint
A problem with no test cases counts as solved when the passed count is . That is, if then a team with has solved problem .
If every team solved the same number of problems, team wins. The limits are small, so comparing every with directly fits easily.