#K4586. Taco Top Participant
Taco Top Participant
Taco Top Participant
You are given N participants and M problems. Each participant has attempted each problem, and their results are represented in a matrix where each entry is either 1 (problem solved) or 0 (problem unsolved). Your task is to find the participant who solved the maximum number of problems along with the number of problems they solved. In the case of ties, choose the participant with the smallest ID (participants are numbered from 1 to N).
The input is provided via standard input and the output should be written to standard output.
The mathematical formulation of the problem is as follows:
Given a matrix \(A\) of size \(N \times M\), where \(A_{ij} = 1\) if participant \(i\) solved problem \(j\) and \(0\) otherwise, find the index \(p\) and count \(c\) such that: \[ p = \min \{ i \mid \sum_{j=1}^{M} A_{ij} = \max_{1 \leq k \leq N} \sum_{j=1}^{M} A_{kj} \} \] \[ c = \max_{1 \leq k \leq N} \sum_{j=1}^{M} A_{kj} \]
inputFormat
The first line of input contains two space-separated integers N and M — the number of participants and the number of problems, respectively.
The following N lines each contain M space-separated integers (either 0 or 1) representing the problem-solving results of each participant.
outputFormat
Output two space-separated integers: the ID of the participant with the highest number of solved problems and the number of problems solved.
## sample5 4
1 0 0 1
1 1 1 0
0 1 0 1
1 1 0 0
0 0 1 1
2 3