Connection Status:
Competition Arena > Scoreboard
SRM 78 · 2002-04-08 · by dpecora · Simple Math
Class Name: Scoreboard
Return Type: int
Method Name: getScore
Arg Types: (string)
Problem Statement

Problem Statement

You have been hired by a gaming company that makes pinball machines. They are currently making a simple and small pinball machine designed for kids' home use. As the company's newest Pinball Engineer, your job is to make sure that the right score is displayed on the machine. Players can get points by hitting bumpers, moving over rollers, or executing a tricky sequence which gets them the jackpot or double jackpot.

Write a function which returns the correct number of points the player has earned so far. The input string, events, consists of characters indicating what has happened:

  • 'B' indicates the ball hit a large bumper. This is worth 1,000 points.
  • 'b' indicates the ball hit a small bumper. This is worth 250 points.
  • 'R' indicates the ball went over a roller. This is worth a measly 50 points.
  • 'J' means the player got the jackpot and earns 10,000 points.
  • 'D' means the player got the double jackpot and gets 20,000 points.

Constraints

  • Events will have a length from 0 to 50 characters, inclusive.
  • Events will have no characters other than 'B', 'b', 'R', 'J', and 'D'.
Examples
0)
"BBB"
Returns: 3000

Three large bumpers, at 1000 points each, is worth 3000 points.

1)
"BbRJD"
Returns: 31300

One of each scoring: B = 1000, b = 250, R = 50, J = 10000, D = 20000 => Total = 31300

2)
""
Returns: 0

Much sadness, as there was no score at all.

3)
"JJRRBbD"
Returns: 41350
4)
"bbRRBD"
Returns: 21600

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

Coding Area

Language: C++17 · define a public class Scoreboard with a public method int getScore(string events) · 27 test cases · 2 s / 256 MB per case

Submitting as anonymous