Connection Status:
Competition Arena > Soccer
SRM 140 · 2003-03-26 · by Yarin · Simple Math
Class Name: Soccer
Return Type: int
Method Name: maxPoints
Arg Types: (vector<int>, vector<int>)
Problem Statement

Problem Statement

In soccer leagues, the winner of a match is awarded with 3 points and the loser 0 points. In case of a tie, both teams are awarded with 1 point each.

Create a class Soccer containing the method maxPoints which takes a int[] wins, the number of wins for each team in the league, and a int[] ties, the number of ties for each team in the league and returns an int, the maximum points a team in the league has. The i'th elements of wins and ties correspond to the number of wins and ties respectively for team i.

Notes

  • Two or more teams may have the same number of points.

Constraints

  • wins will contain between 1 and 50 elements, inclusive.
  • ties will contain between 1 and 50 elements, inclusive.
  • wins will contain the same number of elements as ties.
  • Each element in wins will be between 0 and 100, inclusive.
  • Each element in ties will be between 0 and 100, inclusive.
Examples
0)
{1,4,3,0,0}
{3,1,5,3,1}
Returns: 14

The number of points for each team are: Team 0: 3*1 + 1*3 = 6 points Team 1: 3*4 + 1*1 = 13 points Team 2: 3*3 + 1*5 = 14 points Team 3: 3*0 + 1*3 = 3 points Team 4: 3*0 + 1*1 = 1 point So team 2 has the most number of points, 14. The method should thus return 14.

1)
{12,45,20,17,48,0}
{48,10,53,94,0,100}
Returns: 145

Both team 1 and team 3 got 145 points, which is the maximum.

2)
{35,0}
{0,76}
Returns: 105
3)
{0,0,0,0}
{0,0,0,0}
Returns: 0
4)
{13,79,26,73,14,89,71,37,89,71,19,59,39}
{88,27,5,70,84,94,20,50,2,11,31,22,50}
Returns: 361

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

Coding Area

Language: C++17 · define a public class Soccer with a public method int maxPoints(vector<int> wins, vector<int> ties) · 63 test cases · 2 s / 256 MB per case

Submitting as anonymous