Statistics

Problem Statement for "OverallScores"

Problem Statement

Several individuals numbered 0, 1, 2... N-1 are competing in a tournament. Several rounds are played, and a certain number of points are scored each round. The individual with the highest total score sum from all rounds, is the overall winner.

You are given int N, the number of individuals competing. You are also given int[] scores, the score for each individual for each round, where elements 0, 1, 2... give the score for players 0, 1, 2... in the first round, elements N, N+1, N+2... give the scores from the second round, and so on.

Return the index of the player with the highest total score. If there is a tie, return the lowest index of those players that were tied.

Definition

Class:
OverallScores
Method:
findWinner
Parameters:
int, int[]
Returns:
int
Method signature:
int findWinner(int N, int[] scores)
(be sure your method is public)

Constraints

  • N will be between 2 and 10, inclusive.
  • The number of elements in scores will be divisible by N.
  • scores will contain between 2 and 50 elements, inclusive.
  • Each element of scores will be between 0 and 100, inclusive.

Examples

  1. 2

    { 10, 20, 30, 40 }

    Returns: 1

    Player 0 scored 10+30 = 40, while player 1 scored 20+40 = 60.

  2. 2

    { 1, 1, 1, 1 }

    Returns: 0

    It's a tie with 2 points each, so we choose the lower index.

  3. 3

    { 71, 23, 18, 15, 28, 93, 11, 12, 13 }

    Returns: 2

    Player 2 had one very big score for the middle round.

  4. 2

    { 11, 2, 3, 4, 5, 6 }

    Returns: 0

  5. 3

    { 1, 2, 3, 4, 5, 6 }

    Returns: 2

  6. 2

    {20, 10, 20, 10 }

    Returns: 0

  7. 2

    {1, 1, 1, 2 }

    Returns: 1

  8. 2

    {1, 2, 1, 2 }

    Returns: 1

  9. 2

    {1, 1, 2, 1, 1, 10 }

    Returns: 1

  10. 3

    {71, 23, 18, 15, 28, 93, 11, 12, 13 }

    Returns: 2

  11. 2

    {10, 20, 30, 40 }

    Returns: 1

  12. 2

    {40, 30, 20, 10 }

    Returns: 0

  13. 2

    {0, 0, 0, 0, 0, 1 }

    Returns: 1

  14. 2

    {0, 0, 0, 0 }

    Returns: 0


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: