Connection Status:
Competition Arena > Average
SRM 89 · 2002-05-16 · by dgoodman · Simple Math, Simple Search, Iteration
Class Name: Average
Return Type: int
Method Name: belowAvg
Arg Types: (vector<int>, vector<int>)
Problem Statement

Problem Statement

You have acquired a list of the math and verbal test scores from all the children in the county. Write a class Average that contains a method belowAvg that takes two int[], math and verbal, representing the math and verbal scores of all of the children in the county, and returns the number of children who have a composite score which is below average in the county.

The composite score is defined to be the sum of a child's math and verbal scores.

Notes

  • each element of math corresponds to the element with the same index in verbal.
  • the number of children is the length of math and verbal.

Constraints

  • math and verbal will contain the same number of elements.
  • math will contain between 1 and 50 elements, inclusive.
  • each value in math and in verbal is between 200 and 800, inclusive.
Examples
0)
{200,250,700,700}
{400,400,400,400}
Returns: 2

The composite scores of the 4 children are 600, 650, 1100, and 1100 and the average composite score is 862.5, so 2 of the children are below average.

1)
{500,400}
{300,400}
Returns: 0

Both children have the same composite score 800 which is also the average. Neither are below average

2)
{293}
{799}
Returns: 0
3)
{400,400,400,400,400,400,401}
{400,400,400,400,400,400,400}
Returns: 6

The average composite score is just above 800, so 6 of the 7 children are below average.

4)
{707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707}
{707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707}
Returns: 0

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

Coding Area

Language: C++17 · define a public class Average with a public method int belowAvg(vector<int> math, vector<int> verbal) · 39 test cases · 2 s / 256 MB per case

Submitting as anonymous