Count how many problems each team fully solved (S = T), then report the team with the most solves, breaking ties by smallest index.
Easy1ArrayImplementationNo attempts yetTime limit2sMemory limit512 MBThere are N teams numbered 1 to N and M problems numbered 1 to M. Problem j has Tj test cases. Every team submitted exactly one solution to every problem, and team i passed Si,j test cases on problem j.
A team is counted as having solved problem j only when it passed all of its test cases, that is when Si,j=Tj. 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.
The first line contains two integers N and M, separated by a space (1≤N,M≤100), denoting the number of teams and the number of problems.
The second line contains M integers T1,T2,…,TM, separated by spaces (0≤Tj≤100), denoting the number of test cases of each problem.
Each of the following N lines contains M integers. The j-th integer on the i-th of these lines is Si,j (0≤Si,j≤Tj), the number of test cases passed by team i on problem j.
Print the index of the winning team on one line.
A problem with no test cases counts as solved when the passed count is 0. That is, if Tj=0 then a team with Si,j=0 has solved problem j.
If every team solved the same number of problems, team 1 wins. The limits are small, so comparing every Si,j with Tj directly fits easily.