Statistics

Problem Statement for "Typing"

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.

Definition

Class:
Typing
Method:
speed
Parameters:
int[], int[]
Returns:
int
Method signature:
int speed(int[] rates, int[] freq)
(be sure your method is public)

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

  1. {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.

  2. {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. {3,4,5,6,7}

    {10,20,30,40,0}

    Returns: 5

  4. {10,10,13}

    {34,33,33}

    Returns: 10

  5. {1,1,1,1,1,1,1,1,1,1,1}

    {9,9,9,9,9,9,9,9,9,9,10}

    Returns: 1

  6. {1,2,3,4,5,6,7,8,9,10,11,12,13,14}

    {1,2,3,4,5,6,7,8,9,10,11,12,13,9}

    Returns: 9

  7. {9141,5716,2467,2033,3729,2587,1970,9235,8744,4416,2242,5599,8107,5610,922,6992,4337,9369,7501,2994,7430,2451,1798,5412,1305,8380,1177,5918,4665,699,8966,8048,3195,2098,5550,8195,440,2285,7902,7397,5386,7318,2958,770}

    {2,2,2,2,3,1,3,4,2,1,1,1,1,3,1,2,3,1,3,2,1,3,4,4,3,2,2,1,4,3,1,2,1,1,4,2,2,3,4,2,1,3,2,5}

    Returns: 4693

  8. {7691,8313,9161,9018,1539,315,9749,3157,477,9267,8253,1080,2098,2684,2478,4414,4535,1770,3299,3248,3499,6812,8033,6197,8951,4244,5800,3939,2361,9699}

    {2,2,2,4,5,3,3,3,2,3,5,5,1,1,4,6,3,3,5,2,3,6,2,1,2,1,6,7,5,3}

    Returns: 4913

  9. {9133,7958,8763,7189,1557,9152,618,642,6558,4387,6753,9179,7392,7423,3960,5389,5118,2266,2769,3866,5784,2774,3355,1548,4975,9218,9825,4333,7918,2953,6277,5574,5043,8686,3552,496,4804,4907,6496,6847,7884,6976,7711,6149,9469,4084,5283}

    {1,3,1,3,1,1,3,4,3,1,1,1,1,3,1,1,3,3,4,4,1,3,3,1,3,2,1,3,3,2,2,1,2,3,3,1,1,3,1,1,3,3,1,1,1,2,6}

    Returns: 5237

  10. {8204,9175,5961,9815,4669,9223,175,9017,6016,2756,781,2727,8387,9938,491,8803,7868,7674,4840,1991,7191,579,5064,2310,2810,96,3571,9510,7596,8195,6086,9,2141,244,3693,8524,707,7588,7476,5196,6259,4107}

    {3,1,1,1,2,2,1,3,3,1,1,4,3,1,2,2,1,2,3,3,1,3,3,4,1,1,1,5,1,4,3,4,2,4,1,5,1,4,5,2,1,4}

    Returns: 5336

  11. {8691,1716,6394,764,6819,1908,2493,7457,6368,339,9287,8192,8761,2660,6799,5218,2605,133,436,9668,4611,2679,4954,9181,2911,4407,3864,3035,6286,9524,6118,3419,2086,8716,7666,6365,274,6121,1466,3499,956}

    {2,3,3,3,2,3,3,1,3,3,1,1,2,1,2,4,1,1,3,3,4,2,3,3,3,1,3,3,3,2,2,3,1,4,1,2,4,1,4,5,1}

    Returns: 4529

  12. {3312,9206,5400,8858,686,1561,2813,1389,5998,251,3047,2140,339,5314,1026,7183,6177,4621,7198,406,192,4598,6298,8365,442,9874,1948,5642,3369}

    {2,1,3,5,5,5,3,5,3,3,5,1,2,2,1,2,6,4,3,1,6,6,3,2,2,7,1,1,10}

    Returns: 4189

  13. {9758,6188,5080,8786,741,8974,8494,2046,134,8072,5884,625,4231,8409,8460,8247,5279,2273,4372,9800,1306,4953,3141,7072,8484,9657,5129,405,6200,4934,3800,8215,245,3502,5149}

    {5,1,3,3,1,1,3,4,1,1,3,4,2,2,3,1,1,2,2,3,2,2,3,1,2,2,3,6,7,2,2,8,5,1,8}

    Returns: 5308

  14. {8712,5923,4652,9635,759,5353,8089,8418,4394,2670,6339,859,8848,272,786,1583,1575,2864,4539,227,8190,1979,8894,4642,6140}

    {6,2,6,4,2,2,4,1,5,5,2,6,5,5,1,1,2,5,2,1,10,3,7,4,9}

    Returns: 5353

  15. {5864,7282,8496,3166,4127,1567,9285,9950,8731,3142,9446,901,371,1738,2342,5889,9438,9562,566,8468,4665,5305,7008,9956,9265,4636,5104,8594,2962,7917,1475}

    {4,2,3,1,4,4,1,3,5,4,3,3,5,4,5,3,2,5,3,1,1,3,2,1,5,1,3,6,2,1,10}

    Returns: 5218

  16. {2376,7767,2990,4792,4827,6373,1223,1720,837,4648,8216,7711,7211,8959,4996,3262,8726,2124,9931,3379,918,4243,3898,6711,4885}

    {4,5,6,1,2,5,6,4,2,6,1,4,2,6,5,4,1,4,5,2,1,4,4,5,11}

    Returns: 4960

  17. {9630,3016,3715,9624,493,5518,4383,2534,5000,8145,3244,8343,6789,2978,8587,2986,8814,9288,123,8745,3009,6430,3862,909,3188,976,7093,6609,7094,2221,3480,7747,6842,8937,3097,6320,5705}

    {3,3,4,2,1,2,3,4,3,1,1,3,1,1,2,2,2,3,3,2,5,1,4,2,5,4,2,3,4,5,4,3,2,2,3,1,4}

    Returns: 4937

  18. {7310,5193,7254,1347,396,7500,1639,7834,1842,2948,4587,3858,9138,6068,8990,6379,1334,4285}

    {5,3,4,6,6,9,8,5,1,9,8,8,2,1,1,1,4,19}

    Returns: 4337

  19. {6163,3297,3975,864,1994,468,3863,1059,3847,7740,678}

    {7,6,2,11,15,10,12,1,1,1,34}

    Returns: 1970

  20. {4234,5679,1029,8083,8248,3808,4492,5889,5341,6266,1557,6183,3085,4743,9909,4687,6583,1146,2427,5049,4318}

    {7,4,4,4,3,3,1,1,5,8,7,7,8,6,2,6,5,5,2,4,8}

    Returns: 4656

  21. {7384,3300,3726,824,820,9481,9990,1487,3188,1002,6024,2144,4272,9893,9181,8802,5739,4374,1849,7273,9791,7723,3209,2966,8132,3857,9321,1879,8808,7077,1294,2938,6711,837,8401,4386,2027,517,5461,7237,9790,8177,1536,6925,2820,3077,45,256,9798,302}

    {3,3,1,1,1,3,2,2,2,3,3,1,1,3,1,3,1,2,1,2,1,1,1,1,3,1,1,2,2,3,3,1,3,4,1,1,3,2,4,2,2,1,4,3,1,3,2,2,2,1}

    Returns: 4964

  22. {8989,5655,3829,5682,2898,8990,6991,6945,1450,127,9168,8441,5622,6909,4763,4477,1649,5760,3656,5843,9427}

    {2,4,3,3,3,7,7,8,4,1,7,8,6,5,6,6,1,3,5,3,8}

    Returns: 6367

  23. {6578,1453,4912,1063,7548}

    {11,25,26,21,17}

    Returns: 3870

  24. {2817,7662,3842,901,4866,2508,4898,3958,3851,6754,1651,6533,9996,1795,760,7453,4349,2051,1318,4482,7834,4698,737,6581,7957,6041,695,4756,2498,8634,8114,9214,9627,7488,5146,9967,4266,706,6420}

    {2,1,4,1,3,3,3,2,2,1,3,4,2,4,1,1,2,2,3,2,1,2,4,1,1,4,4,5,3,1,4,1,5,4,3,1,2,5,3}

    Returns: 4589

  25. {2096,3761,2972,763,9760,7844,2989,9169,684,8691,1629,2518,5452,205,9425,3837,1643,1852,1977,2546,7524,2086,1070,3125,6074}

    {2,2,2,3,3,5,5,5,6,7,4,1,2,4,1,8,2,4,5,6,7,2,4,5,5}

    Returns: 4180

  26. {3769,5969,2624,7723,1803,4007,2845,1829,8495,5017,7823,7306,4830,3101,766,8861,9148,5180,2477,752,7629,7745,3312,7183,4931,8790,5379,3699,2150,9319,2743,2652,9323,3089,6428,5153,141,260,5286,9164,7200,484,3451,8349,7197}

    {2,1,4,3,1,3,2,1,2,2,3,1,1,3,1,1,3,1,2,4,1,2,3,1,1,1,3,3,3,1,3,3,2,3,2,1,5,2,3,3,2,1,3,3,4}

    Returns: 4733

  27. {4587,2940,8559,4899,2389,9572,7702,3159,8917,8605,2090,8337,1144,3695}

    {6,9,9,1,3,4,10,8,7,13,3,2,8,17}

    Returns: 5528

  28. {4019,1037,8821,4774,1666,5617,676,5648,7804,6648,9704,3210,612,4878,9777,2071,2660,7106,1472,6182,1405,684,70,4359,9133,4574,5296,1471,7839,4013,8545,42,7589}

    {1,2,3,3,2,1,1,3,2,1,2,3,5,4,5,6,4,3,1,3,2,5,5,1,3,2,5,4,5,1,5,6,1}

    Returns: 4342

  29. {471,8290,4100,1170,9677,4183,2971,4808,8813,2081,7923,2117,9822,7816,8127,3826,4394,5314,1183,7470,5287,4407,2928,4251,1583,7020,8205,4171,2524,1619,2534,136,9020,9356,8019,457,6711,1824,5478,5796,9525,9501,8803,927,8112}

    {1,3,2,2,3,1,2,1,3,1,3,3,4,2,2,1,1,3,2,1,3,1,2,3,4,2,3,1,4,1,1,2,2,2,2,4,1,2,1,2,5,2,3,4,2}

    Returns: 5412

  30. {8911,9113,2012,8640,7382,4708,8934}

    {12,5,9,9,8,26,31}

    Returns: 7067

  31. {8799,8750,7171,3618,388,3415,7519,8898,5586}

    {14,3,11,10,15,11,3,25,8}

    Returns: 5975

  32. {321,7995,7102}

    {37,33,30}

    Returns: 4887

  33. {2477,4340,171,2696,2406,6344,4520,8451,883,6947,477,4522,8277,4974,9837,8345,3240,718,4657,4522,2151,4188,2037,2911,4389,4651,9393,1797,5875,1630,2997,2152,7807,1137,5909,7727,2253,7345,116,2327,1392,9106,1692,9962,2574}

    {1,3,2,3,3,2,2,3,3,2,1,3,3,2,3,3,3,2,3,3,3,3,2,1,3,3,2,3,3,1,2,3,3,1,2,2,1,3,2,2,1,1,1,2,0}

    Returns: 4589

  34. {5879,7472,4545,9819,498,4336,6267}

    {20,15,14,7,7,16,21}

    Returns: 5664

  35. {8973,6382,8153,1217,4135,6561,1163,2364,9827,9891,879,8295,5755,8756,2283,1585,7101}

    {1,8,6,6,10,4,9,5,6,3,6,6,1,9,3,8,9}

    Returns: 5178

  36. {3981,8752,4330,1724,8603,1000,2526}

    {7,10,16,15,4,19,29}

    Returns: 3371

  37. {5331,6408,1703,6483,5335,8949,1561,1219,5592,3927,2723,6919,4270,4045,5128,5977,8275,2179,7025,9441,248,4562,5985,2543,8012,1369,184,7628,8210,9019,5465,5556,2188,8933,8873,2245,8834,850,9965}

    {1,3,2,3,4,4,2,3,3,3,1,1,2,4,1,4,4,1,2,1,1,1,1,1,1,3,3,4,4,4,5,4,2,2,1,1,6,5,2}

    Returns: 5475

  38. {5544,494,6409,1706,3775,309,7109,7916,8749,9427,3058,8482,9437}

    {5,10,10,12,9,1,3,7,6,4,10,13,10}

    Returns: 5536

  39. {5918}

    {100}

    Returns: 5918

  40. {266,6913,3880,1269,3811,5443,3278,1427,3139,9718,5320,239,5305,2066,1357,9993,5313,9136,4527,2228,1765}

    {1,1,6,2,7,7,2,5,5,6,1,7,7,3,4,9,7,5,2,9,4}

    Returns: 4501

  41. {7248,6838,7917,8013,9005,4906,9708,4779,4751,1126,1329,8965,736,3570,8055,2050,8154,5488,2528,79,3796,2485,6210,6112,6096,7827,4562,5087,949,1001}

    {2,2,5,5,4,2,5,5,1,2,2,2,4,5,2,1,1,2,5,1,5,7,2,3,2,3,4,7,2,7}

    Returns: 4900

  42. {1365,7675,9628,7609,4842,8448,3527,8025,7810,9527,5227,9326,6507,7465,6036,5444,1629,1396,1704,1606,8157,5473,5193,4464,7583,2810,4614,2559,8203,9460,8875,566}

    {1,2,3,2,4,3,5,5,4,2,4,3,3,1,5,5,4,2,1,5,2,3,2,3,4,1,2,4,5,1,7,2}

    Returns: 5887

  43. {2104,2865,7455,8770,1024,4581,7507,6728,4654,4246,3694,9887,7362,8356,865,5242,2752,4813,4119,5801,149,2329,5559,3207,9723,565,1284,6920,859,4756,2594,1056,5904,228,1835}

    {3,5,3,3,2,1,1,1,1,5,5,1,5,5,3,2,3,4,1,4,3,3,3,1,1,5,4,4,2,1,3,1,5,5,1}

    Returns: 4114

  44. {3989,1737,3263,1798,6597,5364,1613,4811,3682,9265,2083,2443,7048,8296,2995,2274,6480,4763,2532,1475,8389,7029,8990,4013,7631,2140,7998,4831,9388,3112,5665,6147,4748,1219,9833,3351,5780,1125,5165,3157,3315,2017,1583,4647,3381,1052,9782,4630,6321}

    {2,1,1,2,2,1,2,2,1,2,2,2,1,1,3,4,2,1,2,4,2,3,2,2,2,1,1,3,3,1,3,2,3,2,3,2,1,3,3,1,3,1,2,2,3,1,1,4,2}

    Returns: 4629

  45. {3735,4991}

    {38,62}

    Returns: 4513

  46. {736,583,3928,7455,4283,2860,348,1955,3749,8967,2159,4810,3370,8163,3807,4346,8775,2817,9893,6055,5011,1682,4043,2807,8397,3312,3873,9771,5251,7360,2454,5882,1549,4124,1582,6497,8927,8233,2427,2528}

    {2,1,2,4,1,2,3,4,2,1,1,3,3,1,4,3,2,2,4,1,2,2,2,1,1,5,4,2,4,4,3,4,2,1,2,3,4,4,3,1}

    Returns: 4809

  47. {3753,9214,2062,3359,1295,6498,4264,5213,5395,3692,9363,5102,6595,5302,117,6369,5817,8105,167,2845,9983,483,305,9731,3382,9152,1917,8260,7709,8693,6010,6773,983,8236,7395,9939,3116,1339,100,4721,3844}

    {4,1,3,3,4,2,1,2,1,3,3,1,4,2,3,3,1,4,4,3,4,1,2,2,4,3,2,2,2,2,2,3,1,1,3,3,1,1,4,1,4}

    Returns: 5000

  48. {4374,5323,6955,751,172,1790,6235,6750,177,5171,9650,8576,4741,22,1456,3947,9173,5795,3979,594,5486,435,4792,9652,73,719,4523,3218}

    {5,5,4,5,4,1,3,3,2,1,3,3,3,1,5,1,6,1,7,4,5,1,3,3,5,2,8,6}

    Returns: 4267

  49. {2092,6950,351,225,3979,5063,4083,3346,1716,3042,7283,1381}

    {10,10,9,5,11,5,10,10,2,6,4,18}

    Returns: 3137

  50. {3820,4695,5683,9582,1464,4394,6342,5623,6805,7093,4456,7878,4258,1548,4445,2525,7107,9822,1931,1815,5959}

    {3,5,5,7,4,4,4,6,6,1,4,5,6,2,5,4,7,5,8,3,6}

    Returns: 5345

  51. {5410,3061,6034,3445,2714,5204,2571,5191,8234,900,3793,2641,1805,8738,9759,3420,5252,8240,2095,9078}

    {4,3,5,8,1,8,7,1,8,3,1,3,8,9,4,3,9,3,2,10}

    Returns: 5457

  52. {4195,9059,6637,4548,8810,9235,5410,7471,2637,5874,3739,715,965,5319,9208,105,2537,674,530,223,9719,1134,3403,6425,3692,7371,5153,6348,3261,9151,499,3850,2221,1829,6063,3936,6857}

    {1,1,1,1,3,2,1,2,2,5,1,1,5,1,4,2,1,3,1,3,1,4,3,5,3,1,6,5,1,5,4,2,4,1,7,3,4}

    Returns: 4705

  53. {9628,2576,2621,8073,5908,2737,9850,7106,3205,9824,2131,6186,6085,6437,8496,3783,4351,5649,4754,5501,2551,6804,2108,8497,7983,715,767,6318,6771,3935,1007,367,8430,8025,6401,8099,5534,3816,6562,4807,6600,2576,9591,5364}

    {3,2,3,2,2,1,1,1,4,2,2,1,3,3,3,2,2,4,3,1,4,3,1,1,1,2,4,3,1,2,3,1,4,1,4,2,2,2,2,2,4,1,3,2}

    Returns: 5382

  54. {9776,8302,1358,5841,2246,5135,2021,1268,1623,7394,8520,5689,4750,766,955,6078,7793,7389,5361,8035,773,814,9592,5603,2963}

    {1,4,3,4,5,6,4,1,1,2,1,1,6,2,7,3,7,6,5,2,5,3,9,4,8}

    Returns: 4878

  55. {9494,8933,5908,6563,7948,8958,8345,2654,3243,4830,6562,2128,5194,2276,8615,715,676,967,1034,2997,8381,6924,5651,3872,8587,2999,7012,5260}

    {2,3,1,3,2,5,3,4,5,4,6,6,1,4,6,3,4,6,5,1,4,2,4,2,1,5,4,4}

    Returns: 4905

  56. {9028,1968,1891,2178,8927,5645,8235,412,1763,3802,5382,9616,2210,5944,3406,4252,786,34,2894,3898,4211,7394,8936,3474,303}

    {5,2,4,1,2,3,7,6,3,2,6,4,2,6,5,2,3,2,1,6,2,9,6,5,6}

    Returns: 4794

  57. { 3, 4, 5, 6, 7 }

    { 10, 20, 30, 40, 0 }

    Returns: 5

  58. { 100 }

    { 100 }

    Returns: 100

  59. { 10, 20 }

    { 50, 50 }

    Returns: 15

  60. { 10, 15 }

    { 1, 99 }

    Returns: 14

  61. { 50, 50 }

    { 50, 50 }

    Returns: 50

  62. { 1, 2, 3, 4, 5, 6 }

    { 10, 10, 10, 25, 25, 20 }

    Returns: 4

  63. { 1, 5 }

    { 99, 1 }

    Returns: 1

  64. { 55, 11 }

    { 50, 50 }

    Returns: 33

  65. { 5, 6, 10, 15, 7 }

    { 5, 15, 20, 25, 35 }

    Returns: 9

  66. { 3, 3, 3, 3 }

    { 30, 30, 30, 10 }

    Returns: 3


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: