Connection Status:
Competition Arena > TournamentJudging
SRM 408 · 2008-07-01 · by connect4 · Simple Math
Class Name: TournamentJudging
Return Type: int
Method Name: getPoints
Arg Types: (vector<int>, vector<int>)
Problem Statement

Problem Statement

You have just been hired to be a judge in the Thought Challenge Olympics. Your task is to calculate an overall score for a competitor based on his performance in a series of events. For each event, you have given him a raw score. The overall score is the sum of the adjusted scores for each event.

To calculate the adjusted score for an event, divide the raw score by the conversion factor for that event, and round the result to the nearest integer (.5 rounds up). You are given int[]s rawScores and conversionFactors. Element i of rawScores is the raw score you have given for the i-th event, and element i of conversionFactors is the conversion factor for the i-th event. Return the competitor's overall score.

Constraints

  • rawScores will contain between 1 and 50 elements, inclusive.
  • Each element of rawScores will be between 0 and 1,000,000, inclusive.
  • conversionFactor will contain the same number of elements as rawScores.
  • Each element of conversionFactors will be between 1 and 1,000,000, inclusive.
Examples
0)
{10, 20, 30}
{10, 10, 5}
Returns: 9

The competitor receives 1, 2, and 6 points, respectively.

1)
{8, 16, 32}
{10, 10, 5}
Returns: 9

Due to rounding, the competitor again gets 1, 2, and 6 points.

2)
{60, 59}
{24, 24}
Returns: 5

Be careful to correctly round to the nearest integer (0.5 rounds up).

3)
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
{11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
Returns: 1
4)
{1000000,1000000,1000000,1000000,1000000,
1000000,1000000,1000000,1000000,1000000,
1000000,1000000,1000000,1000000,1000000,
1000000,1000000,1000000,1000000,1000000,
1000000,1000000,1000000,1000000,1000000,
1000000,1000000,1000000,1000000,1000000,
1000000,1000000,1000000,1000000,1000000,
1000000,1000000,1000000,1000000,1000000,
1000000,1000000,1000000,1000000,1000000,
1000000,1000000,1000000,1000000,1000000}
{1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1}
Returns: 50000000

Maximum return

5)
{0}
{1}
Returns: 0

Minimum return

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

Coding Area

Language: C++17 · define a public class TournamentJudging with a public method int getPoints(vector<int> rawScores, vector<int> conversionFactor) · 53 test cases · 2 s / 256 MB per case

Submitting as anonymous