Problem 61059. Leaderboard for the Nedball World Cup

At the upcoming inaugural Nedball World Cup, organizers need to track who is in the lead for the coveted Golden Toeplitz trophy, awarded to the player who scores the most hilbs. After each match, they need the current leader and the total number of hilbs they have scored.
Given an m-by-n matrix, S, representing the individual scores of n participants in the m matches in the Nedball World Cup, return two m-element column vectors representing the leading (cumulative) score and the index of the corresponding participant, respectively, after each of the m events.
Example showing input and output for this problem. The input is a matrix, shown as a table with column headers of the player number and row headers of the match number. The output is two vectors, total score and player. The third element of both output vectors is highlighted. The value of the score is 14 and the value of the player is 6. An annotation explains the meaning: after the third match, player 6 is in the lead with a total of 14 hilbs.
That is, S(j,k) represents the number of hilbs scored by player k in match j. The jth element of the first output vector will be the total number of hilbs scored by the player currently in the lead for the Golden Toeplitz. The jth element of the second output will be the index of that current leading player (from 1 to n).
Note that the index of the current leader should only change if the leading score exceeds that of the previous leader. That is, the leader does not change if points are tied.
However, the players are already ordered by their International Nedball Association condition number (a very important statistic for Nedballers), so if there are multiple tied candidates for a new leader (including for the first event), return the lowest index.
Example
Assumptions
To the annoyance of Nedball purists, the organizers have decided to simplify the rules so that the individual hilb scores (that is, the elements of S) will be finite and real-valued. Even though Nedball is famous for its incomprehensibility, a tournament with no matches or no players isn't very interesting, so you can also assume that S will not be empty (that is, m,n ≥ 1). Other than that, do not make any assumptions on the values of the scores, or the dimensions m and n.

Solution Stats

35.71% Correct | 64.29% Incorrect
Last Solution submitted on Nov 18, 2025

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers63

Suggested Problems

More from this Author33

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!