Connection Status:
Competition Arena > OverallScores
Rookie SRM 1 · 2020-11-13 · by erinn · Simple Math
Class Name: OverallScores
Return Type: int
Method Name: findWinner
Arg Types: (int, vector<int>)
Problem Statement

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.

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
0)
2
{ 10, 20, 30, 40 }
Returns: 1

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

1)
2
{ 1, 1, 1, 1 }
Returns: 0

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

2)
3
{ 71, 23, 18, 15, 28, 93, 11, 12, 13 }
Returns: 2

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

3)
2
{ 11, 2, 3, 4, 5, 6 }
Returns: 0
4)
3
{ 1, 2, 3, 4, 5, 6 }
Returns: 2

Submissions are judged against all 14 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class OverallScores with a public method int findWinner(int N, vector<int> scores) · 14 test cases · 2 s / 256 MB per case

Submitting as anonymous