Connection Status:
Competition Arena > Typing
SRM 132 · 2003-02-01 · by lars2520
Class Name: Typing
Return Type: int
Method Name: speed
Arg Types: (vector<int>, vector<int>)
Problem Statement

Problem Statement

People can type different keys at different rates. For example, some people have theorized that it is faster to type keys on the home row because you don't have to move your fingers as much (the home row is the middle row, which is typically where people rest their fingers when not actively typing). As a result, different key layouts have been proposed to take advantage of this. Dvorak, for example, places all of the vowels and commonly used consonants on the home row.

Your task is to create a class Typing with a method speed that takes two int[] as parameters. The first one, rates, will contain the rates at which each key can be typed, in strokes per minute. The second int[], freq, will contain the amount of time spent typing each character as a percentage of total time. Your task is to write a class Typing, with a method speed that, given a int[] of typing rates for individual keys, and a int[] of frequencies for each key, returns the overall typing rate, rounding down.

Notes

  • Each element of rates corresponds to the element of freq with the same index.
  • If the overall rate is not an integer, simply truncate (round down) the fraction.

Constraints

  • rates and freq have between 1 and 50 elements, inclusive, and both contain the same number of elements.
  • each element of rates is between 1 and 10,000, inclusive
  • each element of freq is between 0 and 100, inclusive
  • the sum of all the elements of freq is 100
Examples
0)
{10,20}
{50,50}
Returns: 15

Since half of the time is spent typing at a rate of 10, and the other half is spent at a rate of 20, the overall rate is 15.

1)
{10000}
{100}
Returns: 10000

Since 100% of the typing occurs at a rate of 10,000 strokes per minute, the overall speed is 10,000 strokes per minute.

2)
{3,4,5,6,7}
{10,20,30,40,0}
Returns: 5
3)
{10,10,13}
{34,33,33}
Returns: 10
4)
{1,1,1,1,1,1,1,1,1,1,1}
{9,9,9,9,9,9,9,9,9,9,10}
Returns: 1

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

Coding Area

Language: C++17 · define a public class Typing with a public method int speed(vector<int> rates, vector<int> freq) · 66 test cases · 2 s / 256 MB per case

Submitting as anonymous