Statistics

Problem Statement for "AlternatingLane"

Problem Statement

Mr. Green owns a beautiful park full of trees. Recently, he arranged a new lane in the park and planted N trees along the lane. The trees are numbered from 0 to N-1 in the order that they occur along the lane. It is known that once the i-th tree grows up, its height in meters will be a random integer uniformly distributed between low[i] and high[i], inclusive.

Mr. Green has quite a strange conception about beauty. In particular, he is very fond of so called alternating sequences of integers, which are defined by the following rules:
  • Every sequence of 1 integer is alternating.
  • A sequence of 2 integers (A, B) is alternating if and only if A is not equal to B.
  • A sequence of 3 integers (A, B, C) is alternating if and only if (A < B and B > C) or (A > B and B < C).
  • A sequence of L, L > 3, integers (A[0], A[1], ..., A[L-1]) is alternating if and only if each triple of consecutive integers in the sequence form an alternating sequence. In other words, each of the sequences (A[0], A[1], A[2]), (A[1], A[2], A[3]), ..., (A[L-3], A[L-2], A[L-1]) must be alternating.
Mr. Green measures the beauty of an alternating sequence as the sum of absolute differences between all pairs of its consecutive elements. In other words, for a sequence (A[0], A[1], ..., A[L-1]), its beauty is equal to |A[0] - A[1]| + |A[1] - A[2]| + ... + |A[L-2] - A[L-1]|. Note that the beauty of a sequence consisting of 1 element is equal to 0.

Once all the trees grow up, Mr. Green will write down their heights in the order that they occur along the lane. If the resulted sequence of integers is alternating, then he will be satisfied with the resulting lane. Otherwise, he will cut some trees down so that the sequence formed by the remaining trees is alternating. If there are several ways to obtain an alternating sequence, he will choose a way among them that results in a sequence with maximum possible beauty.

Return the expected value of the beauty of the resulting sequence.

Definition

Class:
AlternatingLane
Method:
expectedBeauty
Parameters:
int[], int[]
Returns:
double
Method signature:
double expectedBeauty(int[] low, int[] high)
(be sure your method is public)

Notes

  • The returned value must have an absolute or relative error less than 1e-9.

Constraints

  • low will contain between 1 and 50 elements, inclusive.
  • high will contain the same number of elements as low.
  • Each element of low and high will be between 1 and 100,000, inclusive.
  • For each valid index i, low[i] will be less than or equal to high[i].

Examples

  1. {1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000}

    {1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000}

    Returns: 4899951.0

    max answer

  2. {100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1}

    {100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1,100000,1}

    Returns: 4899951.0

    another max answer

  3. {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}

    {100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000}

    Returns: 1633333.3331700016

  4. {1}

    {100}

    Returns: 0.0

    Here we have only 1 tree, so the beauty of the resulting sequence will be 0.

  5. {1, 1, 1}

    {2, 2, 2}

    Returns: 1.0

    Once all the trees grow up, 8 different lanes are possible with equal probability. In cases (1, 1, 1) and (2, 2, 2), Mr. Green will cut 2 trees and the beauty will be 0. In cases (1, 1, 2), (2, 2, 1), (1, 2, 2), (2, 1, 1), he will cut the middle tree and the beauty will be 1. Finally, in cases (1, 2, 1) and (2, 1, 2), he won't cut any trees and the beauty will be 2. Therefore, the answer is (4/8) * 1 + (2/8) * 2 = 1.

  6. {1, 3, 5, 7, 9}

    {2, 4, 6, 8, 10}

    Returns: 8.0

    Here, Mr. Green will always leave only the first and the last trees.

  7. {4, 3, 3, 7}

    {10, 7, 7, 7}

    Returns: 6.171428571428572

  8. {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}

    {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: 0.0

  9. {1}

    {100000}

    Returns: 0.0

  10. {55555}

    {55555}

    Returns: 0.0

  11. {153,340}

    {880,499}

    Returns: 197.8543956043956

  12. {5,4,9}

    {6,5,10}

    Returns: 6.0

  13. {514,464,178,654}

    {637,532,667,770}

    Returns: 502.2245295500154

  14. {16,6,6,14,42}

    {38,17,86,83,58}

    Returns: 93.8313498453595

  15. {48,25,52,21,11,54}

    {80,64,79,52,14,74}

    Returns: 146.88636363636363

  16. {9,1,4,45,11,1,17}

    {91,54,82,91,36,31,65}

    Returns: 167.07797416061658

  17. {146,18,536,383,74,367,10,394}

    {153,216,965,928,597,912,800,415}

    Returns: 2015.0929997217636

  18. {1,2,2,8,2,2,1,6,4}

    {3,5,8,8,3,5,9,10,5}

    Returns: 23.186507936507937

  19. {8833,14149,58287,64867,22357,2792,57966,26618,13276,30841}

    {55226,28210,80542,91900,84621,98447,67481,95934,26675,60894}

    Returns: 237813.4050397304

  20. {336,199,353,826,476,606,163,716,527,145,138}

    {891,285,754,961,507,812,190,934,1000,730,524}

    Returns: 3481.7510674110827

  21. {544,522,180,128,360,646,136,315,651,577,599,256}

    {902,638,510,677,840,920,593,689,699,794,904,792}

    Returns: 2158.6979228729465

  22. {22,35,11,88,30,2,23,31,38,54,15,39,56}

    {74,58,97,95,58,3,25,63,42,80,52,81,99}

    Returns: 326.54429321754753

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

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

    Returns: 37.49074074074074

  24. {287,17,496,357,257,393,557,193,11,594,142,362,367,882,380}

    {937,354,904,438,891,885,776,343,905,844,488,610,531,931,770}

    Returns: 4202.126853416785

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

    {3,4,5,5,10,6,10,5,6,10,7,10,8,3,6,8}

    Returns: 38.01156462585034

  26. {5,3,1,6,2,5,3,9,5,6,6,9,1,6,1,5,5}

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

    Returns: 47.953968253968256

  27. {15870,19735,18287,38917,12277,37806,43377,22610,54427,1403,35418,21692,80577,43807,68202,43695,1595,34307}

    {39272,84085,78239,46358,57008,76892,49750,65346,70177,50967,40692,37693,83915,45462,78006,80473,43221,37344}

    Returns: 387608.2745328143

  28. {19410,61541,72027,57165,17403,6744,52120,45840,13655,64183,83889,16134,32633,7269,78818,3657,6355,8122,19221}

    {32296,85530,77206,68497,34821,90205,85269,82251,92156,91010,83994,37870,59041,28309,85338,71045,17466,64697,28228}

    Returns: 509094.38042878546

  29. {41793,8007,81400,31913,44090,14530,25780,59397,64236,31682,19578,12310,87220,14623,13972,36860,2559,34016,21455,68018}

    {69282,64182,87233,62620,71580,83847,67796,61675,89513,32245,33218,56854,91937,33895,80439,37545,9810,38541,45177,86223}

    Returns: 528736.3921211346

  30. {8993,6912,64649,41103,6040,4910,40805,57713,49227,57785,14292,33260,15558,29480,57560,11613,30362,6007,86237,63458,32859}

    {11908,27613,97365,78432,79695,45254,58560,85831,92762,71381,91913,87907,71259,64234,58898,27989,86732,16896,87331,74119,75986}

    Returns: 542456.0935149934

  31. {540,230,172,305,200,278,857,657,22,689,444,887,654,648,621,24,594,482,182,166,199,189}

    {985,915,778,673,786,537,866,957,119,774,759,943,744,733,622,379,760,693,871,341,424,587}

    Returns: 5352.947891503087

  32. {561,544,101,136,265,99,159,109,366,118,33,32,454,320,197,358,147,89,27,645,438,49,826}

    {886,901,336,188,709,987,507,189,565,747,760,453,987,769,711,810,933,810,71,737,696,212,922}

    Returns: 6573.831051362502

  33. {300,119,41,53,227,566,369,29,516,397,137,146,210,148,255,695,677,313,430,751,789,222,175,101}

    {643,651,539,664,589,852,570,507,645,760,518,381,800,180,489,695,887,809,707,950,864,403,491,719}

    Returns: 4954.725916451024

  34. {33,32,60,40,69,12,37,20,61,36,68,90,44,91,63,7,6,40,8,3,5,58,13,47,63}

    {84,44,97,53,84,57,94,100,61,78,72,99,54,93,65,66,94,43,84,61,19,67,32,64,100}

    Returns: 703.9465736524523

  35. {71245,37471,26497,12681,23885,96874,6458,13863,62779,77192,57912,63563,3297,91656,22639,44034,50793,19756,43038,4150,69984,45793,57440,37891,807,18400}

    {77943,83045,46114,97435,78990,97079,12635,15142,91715,98806,60439,75605,27164,91732,88079,49483,59640,67440,65742,40043,89782,62391,92928,48258,53332,32040}

    Returns: 766614.0958003382

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

    {2,4,8,7,9,7,7,10,6,9,3,4,10,8,10,7,4,7,9,10,10,10,9,6,10,7,6}

    Returns: 59.58018518518519

  37. {43290,64362,13642,36180,45947,24530,37027,18861,27577,40861,39456,72233,11581,33120,15020,81356,56796,6318,16502,24648,4791,29539,38060,34802,35736,10388,38400,68190}

    {45021,88802,48145,49710,79763,67403,49153,64993,53298,98461,54891,94157,99015,93633,93658,96473,57397,53086,18166,87257,61933,31754,56831,74268,98580,50339,86350,76460}

    Returns: 659814.1878091833

  38. {50,42,12,1,5,50,16,49,6,39,2,65,21,19,9,71,60,14,25,8,50,25,42,18,19,72,6,4,3}

    {94,56,72,28,71,55,66,58,53,75,41,66,70,31,11,77,90,92,95,82,84,31,52,26,45,88,41,57,32}

    Returns: 744.4643616956045

  39. {28855,63044,29271,25176,97041,84165,46253,18927,4657,76072,51436,37863,57299,29349,16867,44836,30467,10105,135,7992,67326,24982,51462,73784,39896,9935,3612,30899,16531,22538}

    {55118,70688,66772,47189,98726,99261,87604,53579,74137,81889,79630,76027,92744,36742,54642,98113,94053,68735,17861,90822,74155,69634,52655,82386,65945,72006,50757,99367,81373,39269}

    Returns: 733114.4605093416

  40. {130,599,146,75,598,692,443,624,244,461,369,526,956,64,195,767,289,327,369,116,289,551,76,217,663,201,436,140,494,174,574}

    {639,959,708,893,708,925,729,965,284,778,647,926,996,796,529,848,329,631,566,329,306,834,623,734,970,822,459,557,846,497,685}

    Returns: 8430.35201034263

  41. {1,4,3,1,4,2,10,4,3,8,4,10,1,3,1,2,6,7,6,4,1,3,2,3,5,8,3,6,5,2,6,2}

    {6,5,9,10,10,3,10,7,9,9,5,10,9,10,8,8,7,8,10,5,10,9,6,10,6,10,9,7,8,8,6,6}

    Returns: 90.47906746031747

  42. {3,9,5,8,4,4,3,5,4,2,2,3,5,1,4,3,4,8,3,4,8,2,1,8,1,5,4,4,4,4,3,5,3}

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

    Returns: 86.89788359788362

  43. {308,450,493,37,517,626,812,550,540,389,110,538,153,221,34,382,606,323,250,552,2,768,691,75,153,864,219,541,39,615,499,127,23,52}

    {317,641,896,430,688,764,837,645,600,992,607,838,718,847,389,879,643,533,663,749,16,892,950,887,646,920,541,691,207,856,634,914,574,867}

    Returns: 9821.302390034618

  44. {15,32,3,13,8,61,21,17,71,67,6,57,16,35,27,11,36,54,65,65,29,25,17,24,20,12,41,39,28,13,13,89,24,8,50}

    {67,53,31,48,71,86,80,93,80,89,95,71,79,44,60,50,64,62,93,67,72,47,27,73,40,41,64,70,96,76,73,94,90,25,63}

    Returns: 739.9808973018561

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

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

    Returns: 105.25568783068783

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

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

    Returns: 97.17502645502645

  47. {66420,41379,48002,62258,27725,78544,14151,40318,79326,31924,71983,16557,28421,35037,52623,30896,25705,42171,5714,27274,22061,12117,164,55813,63076,44738,32341,48329,38700,79765,45985,27187,40625,13106,15729,49878,15419,88734}

    {87729,72592,75505,90358,41738,84940,65122,49016,95850,90308,82796,63733,77508,98414,72393,81548,88124,95671,58581,36264,87895,48437,2411,94631,79172,56903,46718,92230,75592,94509,60687,93929,87057,97682,46798,81466,97072,89212}

    Returns: 969885.2215425364

  48. {7869,5939,1198,1384,5653,7173,429,152,1571,2244,5813,6550,6664,2734,3625,2104,8218,8886,3701,1180,7396,5453,5962,1576,4763,7706,4201,7529,6921,4635,796,2214,3578,3808,3200,502,198,1815,854}

    {8456,9210,5441,2590,5917,9898,2703,4943,2743,3232,6154,7146,8010,9001,8413,4202,9824,9755,8065,8447,9612,8823,9974,9178,9487,9623,7036,8551,9668,6422,1393,7486,3825,5438,7152,2965,3911,9986,3450}

    Returns: 93842.56027272709

  49. {47,32,44,14,75,45,26,23,29,2,30,12,75,90,63,7,59,68,31,70,10,7,68,16,58,4,61,71,75,15,9,14,31,29,18,7,48,13,67,49}

    {68,73,79,100,76,92,56,81,86,35,31,19,77,100,67,43,78,100,44,90,35,35,79,31,59,30,83,80,79,53,77,28,94,94,53,81,72,68,93,90}

    Returns: 1129.1177743523267

  50. {297,61,120,666,624,10,328,49,130,90,85,298,166,413,234,38,130,391,296,583,595,43,20,422,661,397,52,191,43,101,672,8,37,8,497,69,206,639,102,507,493}

    {650,958,588,694,806,201,494,750,752,344,459,472,976,893,251,659,943,942,329,779,807,401,837,736,769,836,286,988,992,399,709,153,821,935,738,954,384,854,455,636,843}

    Returns: 11659.453496623028

  51. {52,81414,6799,12548,61246,1580,81732,20342,24527,33745,49409,4196,19363,4442,7476,46580,14020,5089,4676,47206,37804,542,58696,40185,27237,4089,21918,10063,18901,2195,12231,17390,6901,15234,28390,90087,22028,13001,51002,434,18231,3462}

    {61245,86612,62612,17785,89541,2056,92334,83644,25135,41555,80663,7539,45457,63379,22095,66634,73068,44846,5687,85549,44941,43398,63969,65830,47440,43690,82734,66552,66316,25227,84924,82718,61062,40708,47203,92612,59951,98107,61944,33131,35069,66105}

    Returns: 1283141.7992976215

  52. {7551,4659,2742,5862,1166,7736,1534,8198,3452,5658,2884,3129,4119,91,4448,4212,2351,1507,471,1718,2487,1564,1639,2853,491,1254,6188,7550,1775,798,4859,2840,5298,3077,5584,5259,6399,2439,1923,131,4359,3111,919}

    {8162,8495,9703,5880,6571,9369,1957,8282,8674,8443,4855,7578,8636,9371,7178,9758,3653,8821,8366,9617,5074,4510,1648,6245,3275,8752,8977,8332,8557,7544,6353,8285,7413,9319,9367,7000,7137,3729,3481,441,5491,5757,6559}

    Returns: 101672.97716886493

  53. {7,7,17,5,51,13,15,3,43,38,8,78,12,65,8,66,14,23,36,24,17,4,4,25,6,39,74,74,18,32,56,18,46,22,9,32,79,10,88,25,65,24,3,21}

    {91,18,55,81,60,47,54,57,71,76,53,90,57,91,66,73,28,83,85,95,28,86,63,45,29,77,91,75,18,34,76,55,60,65,22,63,89,44,93,95,77,26,78,93}

    Returns: 1290.8918084424154

  54. {2785,2387,2260,951,4069,4887,1946,6967,7340,1386,5368,5424,8151,2890,3004,9743,5221,786,263,3533,172,501,63,3410,1673,3489,4947,2277,2366,629,2249,4367,18,613,396,3212,2311,6732,7129,6015,1778,2974,2680,882,2301}

    {7098,2844,2564,2832,7354,6414,6887,9204,7939,9373,6068,7752,9979,7242,3690,9783,5560,3319,3956,5079,6900,4838,275,7648,3423,7759,8904,5090,5295,8864,4733,9898,977,1681,498,3438,4036,7216,8575,8439,5647,3049,7150,6582,2528}

    Returns: 103974.49556304861

  55. {22478,3574,30718,27183,2176,5247,47409,46090,1182,66699,53289,10761,53373,8170,20581,48309,3899,6839,11365,2611,13734,4737,1765,21928,81342,17637,29278,22453,43742,18941,47358,33798,71118,25936,66184,755,11014,53921,47548,30975,2124,67416,3670,59525,20,25158}

    {98124,60763,48750,95654,7432,75804,84454,59522,7666,89030,88968,55560,57849,60830,79927,74674,55002,15510,61385,26965,65213,75340,15482,75273,97753,71656,71812,77086,81952,93938,88357,96859,90294,46533,88484,70547,88077,72310,65767,94926,95330,68086,55317,81846,72768,43878}

    Returns: 1291023.7288117912

  56. {5855,3229,5460,1762,5292,2280,5219,5947,8991,5332,4274,2733,6129,5872,839,2397,4169,2187,5305,5484,7845,2420,4066,2397,6128,6246,4791,1279,8149,2551,2583,2332,6167,411,6505,7752,109,7966,3037,1867,8336,2830,109,368,1866,662,6663}

    {8082,8764,9882,4565,9476,6370,6390,9120,9000,8834,9035,5379,8912,6303,8435,4932,9904,4761,7865,6647,8299,2475,9467,8026,7066,8293,7018,7738,8908,6995,8540,3385,9751,6015,7062,9879,3672,8026,9522,2413,8839,5485,6319,2110,5014,2959,8526}

    Returns: 138140.5542072493

  57. {4,436,531,733,417,126,819,565,321,188,179,260,204,23,70,53,870,59,495,139,174,390,724,79,432,119,12,470,191,52,877,228,576,32,375,700,208,293,600,472,161,462,59,200,69,973,149,13}

    {965,756,878,898,622,914,897,975,329,996,391,815,223,909,402,249,882,714,558,827,469,970,945,853,874,525,12,689,271,230,951,959,702,767,813,819,539,948,842,516,171,707,229,835,852,991,657,16}

    Returns: 14823.201735091003

  58. {758,124,118,186,26,187,19,597,16,11,251,118,463,60,53,74,617,77,513,590,182,468,264,416,441,147,426,469,382,215,224,503,380,340,744,592,599,44,415,674,311,733,11,65,584,594,764,660,566}

    {837,647,969,368,801,687,712,617,59,375,982,591,465,268,765,830,691,616,773,680,547,958,575,559,503,300,993,947,680,369,923,874,598,999,983,779,988,577,555,788,584,839,421,444,939,683,905,913,930}

    Returns: 12369.94985622414

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

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

    Returns: 134.0248677248677

  60. {13,42,57,94,25,33,16,34,81,11,13,45,49,18,61,71,71,17,7,33,37,17,50,20,15,52,51,49,7,39,40,16,19,61,68,34,16,1,74,32,53,23,17,10,44,65,48,68,60,9}

    {19,52,75,99,36,71,62,93,92,32,33,76,74,45,80,82,73,43,17,68,44,78,87,30,65,78,90,69,66,95,74,71,39,93,88,35,93,74,90,58,97,65,96,96,65,84,100,82,74,66}

    Returns: 1271.1905027440855

  61. {351,527,152,413,263,726,4,305,121,490,453,585,148,450,138,338,130,661,6,177,238,737,90,631,463,244,279,216,160,523,156,308,712,429,8,354,88,481,752,437,652,30,545,919,31,437,35,748,345,66}

    {990,987,693,576,390,731,890,640,513,509,530,882,872,739,861,678,962,748,888,898,339,740,286,856,649,355,407,397,278,741,875,667,734,923,209,518,680,877,827,946,811,52,748,963,304,599,297,851,526,354}

    Returns: 14034.667558394029

  62. {6642,229,3210,905,6493,8452,4832,2253,504,2378,5041,652,1664,7893,2380,3079,2499,7697,7621,2068,3649,9010,3163,2980,1620,5273,3902,5557,6668,4056,2229,2458,2945,1422,1979,4911,1320,7351,4880,5639,1665,7682,2411,7276,722,2468,7838,1721,5763,8939}

    {6759,6189,9072,9554,8699,9759,6446,2418,1460,3486,7471,9268,5223,8408,5128,9609,3546,9168,9475,4832,7111,9337,5083,9874,5070,9573,7866,6656,6997,5412,4905,8247,6483,2816,9852,8515,2801,9447,9136,6088,9720,8029,9011,7839,4246,7901,9367,1848,9573,9078}

    Returns: 146769.92397472553

  63. {19230,42115,42981,64151,51280,46584,1715,6949,6245,20475,17389,38701,50539,40715,46691,27258,29199,56556,31710,32151,9798,74052,10954,91899,29937,3245,52055,87640,33798,31385,787,54961,28211,13246,26612,87378,30512,9750,37587,5783,33949,18741,48506,37365,77691,29990,67182,34581,6925,11139}

    {70948,98410,89359,89518,94402,56507,37700,80284,98135,82077,42344,78010,91334,43181,58124,30102,94417,85823,82948,93184,89104,96358,96540,99122,39431,86233,92281,91786,93891,92115,85311,95732,68342,37001,31077,99114,84578,32293,61017,89810,73055,33080,98839,76154,96828,40465,99036,64755,34664,16115}

    Returns: 1374676.9579633186

  64. {772,3489,4509,7022,8886,11311,12369,14224,16520,18938,20599,23389,24475,27592,29064,30630,32421,34001,36289,39350,41405,42203,44319,46106,48454,50290,52700,55464,56579,58539,61268,62513,64009,67209,68779,70540,72022,74201,76217,79390,80849,82307,84038,86208,88855,90944,92206,94529,97174,98262}

    {1512,3600,5719,7789,9851,11755,13599,15977,17577,19151,21149,23752,25832,27800,29241,31213,32953,34120,36542,39569,41444,42273,45767,47298,49168,50506,53260,55780,56966,58589,61358,63981,64371,67460,69206,70757,73163,74567,77104,79397,81010,82899,84520,86302,89045,91261,93550,94567,97593,98877}

    Returns: 97427.5

  65. {98809,96632,94776,92279,90852,88409,86163,85150,82341,80575,79040,76297,75056,72969,70817,68114,66019,65392,62668,61315,58217,56544,54281,52442,50936,48208,46612,45399,42626,40066,39171,37642,35412,32025,31145,28265,27226,24174,22706,20775,18170,16908,14761,12077,10445,8339,6201,4646,2800,673}

    {99958,97664,95176,93445,91453,89855,86922,85783,82825,80578,79144,77872,75241,73266,71161,68663,66508,65677,63933,61708,59202,56630,54569,53176,51355,48678,47776,45664,43768,41379,39539,37905,35611,33648,31157,29172,27233,24980,23016,21401,19899,17635,15887,13230,11842,9046,6471,5158,3303,949}

    Returns: 98572.5

  66. {842,10156,12065,6343,9117,11914,14786,13785,22150,25228,19327,28752,24715,28745,30616,31634,33509,33903,41472,36721,37518,40129,43388,51382,48721,47163,51861,51576,52524,61347,61956,57624,63145,61941,66050,70791,68737,68479,70796,74394,76754,82993,84016,81817,84774,85152,84607,91956,92645,96393}

    {6474,10263,13456,7448,9507,12310,20465,17384,22451,25914,20850,28984,28550,32625,33551,33729,38908,41003,42384,44304,40518,46273,49061,51460,52380,53004,53414,53802,55456,61435,64554,63588,65555,66511,66113,73101,69908,76982,74644,74439,79449,83318,85830,84802,88793,91902,88101,94029,93814,96543}

    Returns: 161933.94585673412

  67. {842,10156,12065,6343,9117,11914,14786,13785,22150,25228,19327,28752,24715,28745,30616,31634,33509,33903,41472,36721,37518,40129,43388,51382,48721,47163,51861,51576,52524,61347,61956,57624,63145,61941,66050,70791,68737,68479,70796,74394,76754,82993,84016,81817,84774,85152,84607,91956,92645,96393}

    {6474,10263,13456,7448,9507,12310,20465,17384,22451,25914,20850,28984,28550,32625,33551,33729,38908,41003,42384,44304,40518,46273,49061,51460,52380,53004,53414,53802,55456,61435,64554,63588,65555,66511,66113,73101,69908,76982,74644,74439,79449,83318,85830,84802,88793,91902,88101,94029,93814,96543}

    Returns: 161933.94585673412

  68. {8861,8067,19922,4910,6759,9049,16900,14839,23996,30824,27485,18445,19991,20631,27927,32455,32518,31118,39625,29884,50069,32704,37975,43796,57031,52813,42027,47044,44579,50900,56973,57116,49968,54949,58879,59567,62947,57515,64701,83845,73718,78696,80906,73852,73089,70440,85613,87188,82233,78970}

    {14988,16041,20555,29530,25917,18346,30494,27299,31418,33053,33623,41456,23092,27555,34694,38244,34107,34167,51538,48165,52186,49837,44442,47844,60572,55648,44975,54368,65854,51624,66629,57924,72457,66878,63536,63710,70316,59369,81214,84355,80285,86039,87784,88415,86472,72996,88059,90470,92439,99197}

    Returns: 318655.57667842554

  69. {90375,81091,78794,74271,71342,71999,70576,64756,73886,70418,65737,65577,71212,74541,61159,53852,67563,54733,57702,48567,48712,48240,48007,46447,40459,38451,46074,52354,36782,47751,31192,27760,34690,29371,35684,25897,40048,24264,17219,18466,22880,20602,26848,23091,15557,18956,6658,19517,1845,19681}

    {97552,91552,87772,77159,74320,82693,80622,64865,83239,80667,84607,76477,74193,79553,63254,65314,72562,72816,63860,63558,65807,66821,50116,53507,60352,59947,57108,53372,50198,51849,40762,37293,38055,48997,39614,31406,42149,29353,33358,21099,26150,30057,35144,30795,19107,19559,18104,21156,5074,20830}

    Returns: 339142.0514240494

  70. {16022,7306,29674,22926,24115,12911,37617,8222,17523,24427,24013,30381,44079,37027,23539,48724,32577,29749,22386,29059,33515,29110,23306,35482,57449,37137,45776,53529,32563,39500,65872,69493,41511,55494,57806,37184,42388,74500,60965,40621,58700,45684,53681,48562,72030,54036,75880,70608,55156,60415}

    {49291,12842,50426,52604,49614,37212,43728,45463,56735,31214,50597,42393,60430,45763,25059,59382,60997,41313,43269,32201,64902,39236,50422,67961,58176,60797,51392,65048,52325,58687,80297,76782,61485,74527,76537,76694,67225,76391,73786,60545,81383,46071,55925,78860,86143,85929,94274,95717,96157,64823}

    Returns: 662625.0949962189

  71. {89915,61959,53536,59120,70135,76785,69162,88010,66404,55547,65854,57340,41972,48112,46122,35769,58869,32740,32231,37654,64123,70800,35073,34205,32220,35753,29272,40223,24289,26908,50655,22016,30227,29311,50104,19626,20785,19029,22525,10401,16736,26413,48109,6425,6846,10412,27522,19478,30635,26779}

    {94176,89132,85875,89134,74158,89944,92580,89070,73134,89300,75693,63823,81435,67025,57612,52025,61268,42335,57857,39401,78362,72840,51799,70308,56329,70275,39836,43607,26522,48320,65580,67236,39261,63502,60302,41830,27961,61529,42906,51289,26702,44804,55526,12244,32636,27825,50498,25339,39485,37150}

    Returns: 669375.0023438723

  72. {8,99996,3,99994,2,99994,6,99993,6,99994,2,99997,4,99991,3,99997,3,99991,6,99993,3,99996,1,99998,1,99991,5,99991,7,99995,5,99997,2,99997,2,99997,1,99996,3,99992,1,99992,5,99992,4,99995,1,99998,10,99993}

    {9,99999,5,99998,3,99996,9,100000,8,99995,5,99999,5,99992,4,99998,8,99998,6,100000,4,99999,10,99999,7,99998,5,99998,10,99996,7,99999,8,99998,3,99998,10,99997,8,99996,6,99995,6,99997,10,99995,10,100000,10,99999}

    Returns: 4899541.5

  73. {65,99927,10,99920,68,99970,22,99922,31,99922,12,99965,65,99991,2,99948,68,99957,2,99954,43,99912,61,99933,89,99969,42,99909,4,99932,63,99936,31,99916,63,99937,74,99928,27,99942,51,99932,31,99967,4,99926,15,99916,73,99911}

    {76,99957,22,99923,72,99972,57,99932,67,99960,80,99965,76,99992,94,99979,70,99957,24,99985,58,99973,76,99993,96,99987,43,99930,23,99938,94,99957,94,99950,82,99951,97,99965,33,99952,57,99966,89,99975,31,99943,97,99917,75,99967}

    Returns: 4894860.5

  74. {99093,142,99187,659,99027,159,99615,304,99382,352,99065,300,99153,81,99250,51,99773,50,99277,583,99663,73,99521,311,99365,59,99605,80,99576,507,99577,379,99596,70,99251,87,99465,101,99695,533,99592,161,99173,176,99307,661,99003,53,99032,568}

    {99481,167,99418,669,99188,407,99616,718,99485,961,99953,636,99232,220,99461,949,99778,763,99410,940,99859,378,99816,323,99701,571,99753,115,99892,680,99967,675,99701,592,99257,739,99987,625,99856,626,99630,673,99871,660,99705,861,99428,69,99444,690}

    Returns: 4855267.0

  75. {95035,3512,90933,6446,91588,4051,91458,721,94344,6180,95844,4082,90335,2197,90806,2913,91737,3948,99410,3095,95133,285,91287,5255,91681,3409,92355,278,92608,1827,93492,5176,90510,2022,99328,2300,97997,1001,90059,2375,91675,2748,91234,8,93809,2148,90457,6606,93934,9378}

    {98467,8769,91142,7375,94965,5828,97848,4177,96482,8039,95887,8235,93022,5735,91665,5528,98957,5572,99549,8347,95321,9786,95901,7176,94905,9916,93142,9484,94030,7799,96026,5905,94855,5470,99597,2562,98019,1872,94436,7698,93107,6219,96084,4162,94760,6514,92441,9828,95766,9416}

    Returns: 4372696.0

  76. {74230,22249,74644,24375,60126,15542,59912,15748,61610,16993,67262,551,76881,27741,63138,32754,76947,29376,79229,26545,55600,9982,62281,29070,55759,26057,57801,12489,64773,5456,62745,3745,61827,16882,50098,21723,59373,29127,50423,1359,67820,35032,96329,5064,58633,29921,66825,3361,53059,2390}

    {90580,23537,86539,32195,91705,19080,85796,31620,97543,22841,79135,40088,89142,47979,70094,45878,77617,39823,86675,47478,61680,46306,63862,46717,66589,40272,59861,45352,72500,45492,75682,35760,97644,21300,97374,22242,73962,42059,54073,38695,97209,42287,98370,49121,85036,36458,96247,39611,60096,45586}

    Returns: 2182610.0

  77. {24503,91385,70416,51376,4006,36253,48482,39516,11223,77383,13641,72844,2,32444,28405,62713,39131,63503,71981,40777,14718,60067,14363,41259,8722,44365,2242,33519,7910,41711,4139,33147,64043,46627,28151,65971,2652,46161,51522,59282,19758,67352,4704,78278,19760,28507,12562,41034,4516,66037}

    {30808,97479,70520,55341,47380,36315,63268,90023,71781,77864,62822,73521,23836,89164,35279,98980,66600,78483,73151,83264,53935,70717,60542,68641,48303,68272,53082,94115,49241,53868,12834,88706,65154,55471,36639,80770,24671,73621,65941,84335,20353,75286,5961,99579,39432,76733,56363,61357,58801,78493}

    Returns: 1596697.2173674693

  78. {4, 3, 3, 7 }

    {10, 7, 7, 7 }

    Returns: 6.171428571428572

  79. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16263, 69701, 49753, 17257, 58120, 68352, 54109, 18331, 32170, 26918, 37973, 6981, 6224, 67593, 26552, 16191, 40636, 4921, 19311, 37364, 14711, 51877, 50432, 676, 24191, 58135, 41630, 44031, 29127, 34105, 29750, 30257, 35573, 2491, 27120, 37406, 30328, 33498, 66825 }

    {100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 65934, 77744, 91530, 75509, 87257, 99712, 72844, 78706, 46394, 37367, 57933, 69848, 32869, 38550, 88165, 76170, 50428, 42625, 27945, 69863, 98485, 43302, 67237, 79930, 60398, 70492, 59345, 68426, 52728, 41744, 87335, 74761, 65621, 70933, 31614, 54510, 75696, 54050, 56720, 92597 }

    Returns: 1164267.6540346846

  80. {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 }

    {100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000 }

    Returns: 1633333.3331700016

  81. {1, 1, 1, 1, 1 }

    {100000, 100000, 100000, 100000, 100000 }

    Returns: 133333.33332

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

    {100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990, 100000, 99990 }

    Returns: 1633178.1827006664

  83. {94324, 87583, 46186, 45388, 98948 }

    {99999, 99783, 99432, 100000, 99723 }

    Returns: 70620.01055922412

  84. {1, 1000, 34, 54, 43211, 1, 1000, 34, 54, 43211, 1000, 34, 54, 43211, 1, 1000, 34, 54, 1, 1000, 34, 54, 43211, 1, 1000, 34, 54, 43211, 1000, 34, 54, 43211, 1, 1000, 34, 43211, 1, 1000, 34, 54, 43211, 1000, 34, 54, 43211, 1, 1000, 34, 5, 1 }

    {100000, 99563, 54214, 54, 98723, 100000, 99563, 54214, 54, 98723, 99563, 54214, 54, 98723, 100000, 99563, 54214, 54, 100000, 99563, 54214, 54, 98723, 100000, 99563, 54214, 54, 98723, 99563, 54214, 54, 98723, 100000, 99563, 54214, 100000, 99563, 54214, 54, 98723, 99563, 54214, 54, 98723, 100000, 99563, 54214, 54, 10002, 99563 }

    Returns: 1828835.0458379681

  85. {1, 1 }

    {100000, 100000 }

    Returns: 33333.33333

  86. {7, 4, 6, 3 }

    {8, 6, 7, 10 }

    Returns: 6.0

  87. {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, 13, 15, 1, 1, 16, 1, 1, 1, 1, 1, 1, 13 }

    {100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 23440, 12999, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 99999 }

    Returns: 1625109.4989430858

  88. {1, 1, 1 }

    {100000, 100000, 100000 }

    Returns: 66666.66666


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: