Typing
SRM 132 · 2003-02-01 · by lars2520
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
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
{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.
{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.
{3,4,5,6,7}
{10,20,30,40,0}
Returns: 5
{10,10,13}
{34,33,33}
Returns: 10
{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.
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