Statistics

Problem Statement for "WaterTank"

Problem Statement

You are given the int C and the int[]s x and t. You have a water tank with capacity C liters. The tank is initially empty.

At time 0 water will start flowing into the tank through an input pipe. This process will consist of n consecutive intervals, numbered 0 to n-1 in order. Interval i lasts for t[i] seconds. During each second of interval i exactly x[i] liters of water will enter the tank.

The tank also has an output pipe. The water will always leave the tank through the output pipe as quickly as it can. The output pipe has a valve. You can use the valve to set the output pipe to any maximum output rate R (in liters per second). This maximum output rate must remain constant during the entire process. The rate must be nonnegative but it doesn't have to be an integer.

Determine and return the smallest output rate limit R such that the amount of water in the tank will never exceed C liters.

Definition

Class:
WaterTank
Method:
minOutputRate
Parameters:
int[], int[], int
Returns:
double
Method signature:
double minOutputRate(int[] t, int[] x, int C)
(be sure your method is public)

Notes

  • Your return value must have an absolute or relative error smaller than 1e-6.

Constraints

  • n will be between 1 and 50, inclusive.
  • t,x will have exactly n elements.
  • Each element of t will be between 1 and 1,000,000, inclusive.
  • Each element of x will be between 1 and 1,000,000, inclusive.
  • C will be between 1 and 10^9, inclusive.

Examples

  1. {3,3}

    {1,2}

    3

    Returns: 0.9999999999999999

    In this case, we have two time intervals, the first one lasts 3 seconds and water flows at 1 liter per second. The second one lasts 3 seconds and water flows in at 2 liters per second. The answer in this case is 1. During the first interval, water flows in and out at the same rate, while in the second interval, water flows in at a net rate of 1 liter per second. Any lower output rate would cause the tank to overflow 3 liters.

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

    {5,4,3,2,1}

    10

    Returns: 1.9999999999999996

  3. {5949,3198,376,3592,4019,3481,5609,3840,6092,4059}

    {29,38,96,84,10,2,39,27,76,94}

    1000000000

    Returns: 0.0

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

    {123,456,789,1011,1213,1415,1617,1819,2021}

    11

    Returns: 2019.1666666666665

  5. {100}

    {1000}

    12345

    Returns: 876.55

  6. {294152,659431,773807,984996,178320,433743,190533,214507,596274,783487,525293,525524,188188,216499,40428,189387,366211,299892,520361,51754,860151,343536,683132,688463,32295,839749,884813,132499,181982,589029,140667,690285,893552,407497,398005,534456,720529,933780,813081}

    {563428,849126,205858,523741,536602,385138,677872,795730,480743,819747,750918,641588,331302,125843,212319,491912,23823,696418,250965,343599,494835,657525,954974,958256,885669,973114,115254,298353,314581,97971,757488,205893,985898,783666,431505,505169,464455,397279,49682}

    804472

    Returns: 985897.0996920157

  7. {77305,226094,890516,551652,874827,80845,757573,851438,488181,858963,746742,746672,561833,594903,584922,15854,482401,648528,511596,448358,133476,748764,549467,512874,228300,21121,784901,185944,288571,932826,92184,525208,295642,180144,771703,865948,404651,289510,514564,969678,882634}

    {85480,144452,331382,508033,675931,798470,617164,913705,628914,403867,937383,340378,676083,731922,359788,860764,590900,174019,653619,938304,19219,179680,88900,488635,751970,905209,502263,223292,103678,904874,748575,192022,635740,592094,186006,413783,194817,499815,26706,366338,124414}

    300138

    Returns: 938303.3305840421

  8. {413764,825115,443650,54976}

    {107444,954791,60003,608397}

    168259

    Returns: 954790.7960781223

  9. {664737,794601,425052}

    {608455,393515,333520}

    93513

    Returns: 608454.8593233112

  10. {688045,838307,124368,190002,844041,1736,88099,979419,13921,581451,256016,741524,954162,22083,219882,459089,122506}

    {565813,922698,608132,387154,134716,235387,829685,996424,855838,930599,154708,491133,13535,307619,495016,205989,547445}

    483303

    Returns: 996423.5065411228

  11. {52005,742822,126071,850895,474966}

    {8474,909910,928686,138528,316533}

    629276

    Returns: 928681.0085586692

  12. {406090,91418,857701,570635,331023,670298,575017,282426,619058,685515,950863,596399,383229,374439,124701,649435,753123,623411,317988,579793,828631,140212,409943,411491,492720,938336,447635}

    {429068,406218,844158,8293,528043,279956,95770,59843,498613,316461,688226,217498,601328,645932,834049,380127,330071,245174,379084,990478,537094,99612,15990,916338,128064,427201,446346}

    766533

    Returns: 990476.6779195333

  13. {98141,571874,325553,724379,926825,918563,925656,466489,266813,709485,971201,638508,321502,926552,821895,364103,508965,169240,934922,504287,788053,142922,226130,670696,972017,896220,530399,531274,332289,350471,579538,352386,253092,255268,452223,515285,561764,951079,892846}

    {849318,43597,486227,314872,324456,736499,12375,742443,721556,361477,751079,206488,965135,925949,363900,32280,46497,359384,378254,197480,131984,912416,247324,911915,109119,583768,554359,40198,299335,475792,959698,829002,94270,453040,720221,202585,957182,858157,998694}

    909380

    Returns: 998692.9814816888

  14. {81543,647856,891949,183890,194739,483469,341851,166732,874272,738373,518000,454691,304901,483423,159877,782414,911785,725531,933652,762643,284122,358909,421039,614120,981873,515628,295009,881783,799200,63204,332671,196282,813140,759626,498619,835667,207171,495174,321317}

    {695087,430230,223282,244804,496833,419784,91507,998602,605923,324375,594026,116323,929147,956824,498968,361366,777737,917928,402481,835990,875304,690150,858519,809112,861231,105622,25770,702896,4012,352408,814280,799103,39267,203528,667691,824745,403556,79974,926536}

    79491

    Returns: 998601.5232408895

  15. {607373,869022,922501,548549,173582,197070,313957,893560,241943,868198,939433,298087,165404,127385,158328,366940,694885,133301,558021,316273,529343,832240,436125,119737,251980,884648}

    {224148,426706,125567,180587,531197,697192,632447,926038,218763,315353,734873,454269,725268,410279,619472,486945,472045,63414,157057,812344,31274,775161,830010,679745,603977,270672}

    928606

    Returns: 926036.9607793544

  16. {372658,515070,347720}

    {425915,203634,353423}

    780920

    Returns: 425912.9044593166

  17. {954833,473616,940785,930864,485614,717947,845502,304741,663689,772809,258070,452557,148922,956601,671740,30590,843590,459337,831473,322713,287993,80178,181017,115711,336204,540396,848486}

    {305401,100066,923724,609430,67415,785442,179841,156702,984045,344570,258310,868172,762042,760172,834656,439446,103993,744880,545161,520233,619327,517679,642188,99552,833627,534549,586868}

    46009

    Returns: 984044.9306768682

  18. {586678,453710,136190,27441,340609,237938,114086,643668,320039,988416,350521,829998,83942,962977,41956,582777,133475,614043,291825,226247,866125,828546,434332,770691,955411,277614,892277,465499,214162,483120,453599,203566,254260,470856,934290,649242,416879,299079,684654,834138,514637}

    {724951,493216,419284,800258,564096,143377,366993,969732,712148,654879,10929,750494,646914,6215,891322,232716,686065,147877,836771,957109,705278,786233,421997,762508,387519,656370,537739,511173,598340,636846,646692,90166,479153,251675,999554,107638,503738,203482,941698,129659,52829}

    289472

    Returns: 999553.6901690053

  19. {307603,430577,5453,17435,376824,645967,608055,864684,883705,598264,473047,152635,569174,409190,372021,1931,431991,488231,166724,916302,328434,116958,959934,313391,538856,763045,904704,586247,603272,365853,207023}

    {326344,291325,493378,900699,813979,129282,599508,259767,346289,126041,392043,302011,595473,214522,697749,233386,158474,471557,490028,474417,549404,865777,445400,604401,943887,871622,720841,919132,940612,945478,297854}

    560322

    Returns: 945476.4684504431

  20. {729396,533985,43332,674957,949010,240781,975958,27642,70248,145797,629042,904321,104840,684694,323580,429982}

    {642931,295521,910607,252483,899952,79169,839669,589265,389860,768197,237099,707798,984108,401676,266618,171679}

    123630

    Returns: 984106.8207745135

  21. {429962,181263,104824,590092,281253,475983,566039,816092,215114,859453,518901,284237,14659,13767,757010,310006,31147,331381,971151,26431,139221,572093,24372,419632}

    {331354,639566,19647,322715,6869,701315,506089,364649,869808,447043,560029,430551,786607,655670,532893,167735,141992,327447,769828,691442,475936,121600,375860,336631}

    866177

    Returns: 869803.9734047992

  22. {272633,781441}

    {878382,824717}

    248993

    Returns: 878381.0867099727

  23. {556949,648960,322334,877384,791809,480000,102713,64146,225509,38523}

    {135338,901805,920906,659102,531441,800604,917327,715042,145251,274603}

    689212

    Returns: 920903.8618079383

  24. {485163,606071,452520,499687,478105,365023,6689,775817,311293,189056,760370,875598,231692,547542,840739,319027,210046,84281,194430,993648,667136,22274,739116,52767,656071,905942,827033,154619,668734,724174,589458,428123,825334,993682,525081,415152}

    {230979,66136,908179,475005,804865,289363,341640,957843,365185,931342,554782,502358,633337,358276,715630,50053,162139,539928,509236,500171,881621,500597,429515,384878,893410,311988,208314,274883,895725,627389,836457,804088,305520,136458,19206,409850}

    661295

    Returns: 957842.147614708

  25. {541646,203421,258785,788572,630316,539850,622553,284174,107067,549065,601489,688454,497681,843304,794399,825327,87833,214694,569772,253939,122586,716098,443846,244356,970544,575277,270819,143185,425435,347807,705583,982284,869635,148748,529201,321456,982164,893869,463515,609935,37930,228334,43630,801682,615519,224036,965674,565959,707580,986380}

    {1,1,26,6,933293,8,124362,1385,42,10251,267,11,2,2482,21,742,442,288325,905457,5,18,3,2886,518,81,184306,109415,16073,5875,121,58244,14304,282917,274,453028,52923,48058,22,98219,71,7387,143206,64,521,10503,6064,75603,24,186445,8564}

    43478260

    Returns: 933224.0214876347

  26. {243321,612554,209420,271660,527312,854018,19476,180893,319523,300620,158217,143274,865025,239264,708333,735027,964227,726967,578232,75615,588877,173042,441433,263349,213136,582209,78981,838712,4397,41082,295431,825103,859376,816579,622919,10994,768022,127206,228018,657947,141160,246785,792525,745765,547325,105098,652036,198979,770076,961019}

    {15,73302,1,185126,30,2360,6168,93779,781380,196511,746,1224,736811,221,518,29652,4049,2,382280,25,4344,22292,91457,2351,92987,559434,87,28,50123,1114,1575,35077,1,984043,57,45,8,4,439485,7631,4,206046,8,406207,1,10,316687,411,8145,6}

    200000000

    Returns: 983798.0757489477

  27. {256231,791892,439998,911602,585859,476194,684793,581693,110920,82099,541112,127668,9791,391242,856004,236390,294085,164640,988396,130427,810672,962943,706983,868434,680181,192357,510998,638978,282731,520436,655026,335076,344027,756135,429536,600034,23582,394960,925543,94725,161709,292752,594842,952298,3063,350566,406492,258342,781906,668337}

    {46,20,1,506903,620,1102,36,11,22013,422,42,2,668712,28720,5,8071,647527,8420,39990,7448,4123,55978,460,134,16424,339654,123566,4,6,123919,914,738,240861,2,160,1,74,99512,289,18,44,1,18748,518,8154,2033,6613,49,3005,5185}

    50000000

    Returns: 663605.2693289756

  28. {240788,345653,917099,490744,281598,649710,244907,10868,29070,216236,983896,897356,701190,303916,410946,69340,886896,647247,150344,882093,278579,504595,688241,103606,668736,685449,433204,231502,984866,475712,68141,294269,993118,806659,248421,285619,313923,846166,666857,291958,561766,430090,128296,190307,746463,397197,554839,517662,554737,942760}

    {344587,1469,137,263620,935,96,3,74,75,3,664,3790,176995,613,12679,1653,744,108,131194,30930,729117,6115,2076,120063,634789,9444,12,637174,133689,8589,368297,7,1,4,824919,2711,10898,1,103928,30914,105,14796,10320,150120,5,275,1271,2107,1,10}

    2178649

    Returns: 824910.2300127605

  29. {86455,538805,810159,990343,653019,462931,183478,114507,887880,750774,569129,351481,521405,727071,854833,317012,631256,501112,802658,480080,431837,288697,12787,34272,416626,158035,666260,754077,316182,559089,187725,659003,917638,711746,630347,227380,780747,300194,152405,976887,281044,949277,428763,460298,212474,643120,220249,112637,389792,587151}

    {28572,40897,2421,2278,17346,168424,1,1963,453,108953,5,31217,398748,25,238,11089,4908,519497,16044,2060,4482,399,2,91422,18989,12816,7,22412,12,19,2,132207,10,184986,41196,5002,1757,4504,102712,33284,269,124,857168,467,127,11162,3,27,154610,41}

    100

    Returns: 857167.9997667709

  30. {761,468997,407699,680971,979830,200969,88650,637302,910787,695043,269291,302542,796440,270123,833635,532258,255704,650500,685293,110245,251358,378642,250549,380349,351017,247338,597610,991496,651362,295562,843579,408156,617714,229769,345870,984026,869404,355984,156268,948426,375911,237923,353480,612951,619604,332522,164025,470157,27961,796627}

    {379505,67,1,4531,9053,311095,2,382599,1,2,50,25921,6594,103715,807107,2,976537,1796,40907,1937,10,115,81,482,3,953133,113664,41,1,85,812780,1,3,1,71,8,666,73173,132,526,165566,2,94703,6,229719,7,23373,2,684,2}

    3225

    Returns: 976536.9873877608

  31. {933260,295065,755561,666668,754209,247917,991802,954502,97972,746374,877606,471504,150429,769392,65430,372872,574635,569268,806396,814874,753394,552668,818108,128034,249585,499903,599313,827296,838173,298888,356357,44292,437434,101635,8128,151393,146827,698858,444216,188055,385082,952196,325248,197019,814437,323744,234889,731278,335602,899060}

    {5746,194,1105,1,13,600340,3,465295,69224,382579,392,52,2267,39123,8300,404801,47429,12292,5,3238,15,2223,55,115,1,66,6528,28282,1,2393,343421,26471,124,73,176,7,40931,19,6,578882,804732,3421,436,10,165943,253,4904,1,353,2}

    8264462

    Returns: 804710.5384359694

  32. {718408,959757,703523,164883,293977,805936,761782,115244,808208,105028,314476,824053,669395,414395,350483,395667,177557,316564,423544,599010,675168,47848,358411,676309,255283,599835,167908,251970,364627,877653,255285,541226,276883,956897,567052,594287,205385,345386,608559,754144,774600,426406,137905,854775,676244,936883,913321,941399,598553,416891}

    {4107,454461,74964,13117,271,6945,8223,38268,783,412238,31,3297,33313,8762,26,1011,61,557553,199951,151,6612,349,2,134955,373,6,2398,4,16102,117,9207,405,43214,98,2498,821,39819,183,71,23,680555,17290,12438,496,107,570,4,119,3,33}

    5

    Returns: 680554.999993545

  33. {546802,795896,548207,903203,278954,9235,895763,990916,419091,159600,5978,683268,425262,270652,305003,283354,173361,353838,404496,372909,55922,148138,466669,106114,928466,551113,874721,338214,812458,461125,686574,287829,878253,747676,542256,132020,251860,720156,793856,789659,616144,774812,631908,161298,410092,865625,893157,262715,669007,66799}

    {541,414153,2,14682,235364,151,35,43,400856,3,2003,19019,146844,621,8,415,965361,51335,12896,144,337,2,414791,109,524161,38,5540,2455,109193,10776,121,104695,942940,622818,17946,73786,750266,31,18804,1,3,180,3,2,8,511291,24,2,671,49015}

    200000000

    Returns: 964207.3379883595

  34. {155396,780150,313036,61738,88682,549409,415540,202490,914619,143264,969513,690760,949934,573393,562786,243837,605804,734282,313002,924263,197986,326457,708204,236099,941307,123327,187898,588815,650169,744153,543349,39837,70011,944281,822342,403562,824267,188657,186292,397627,677156,935782,86569,486519,184737,626641,202083,478091,834955,846783}

    {1,14,43416,5394,387975,55794,1,85612,3635,46290,770659,256764,2729,81873,1,546076,461,369,129,328,4533,6,411,10028,386481,419,5003,98,3444,2,96,1,8,3,1,357933,2573,9902,210,43,22394,77642,949,22,9,311579,897,276255,178582,1}

    500000000

    Returns: 770143.2771577069

  35. {14,37,523,3,110,7,2,3,1,13,21,29386,5,282197,3,17,3,104996,131845,37,89,2353,14,17,1,441815,1,15,339,53,41913,769602,1829,30,8800,17608,115372,111120,11,6151,5,218468,324,692289,6908,2676,2,17,71784,349}

    {56,3,14,253176,29,1,1485,95,26,238,115452,9,264,936586,303484,8,8642,1624,121023,79,290044,1,150,1257,384532,4771,135025,837620,139194,3099,67,77073,155,28247,290,61,306,5,37,3,17049,37,1339,27944,66,255685,113,24,131,4}

    2

    Returns: 936585.9999929128

  36. {87105,27580,120,1,71,1576,4,17033,251567,169547,65386,91073,37,13,10694,119010,460,44,6531,31,27906,113382,9973,3,25394,8,2074,39,17,31,3744,16400,12,982780,6258,158306,27240,25,2,224206,8747,31,67,21,9,60,175671,117911,16,2}

    {97,39653,857,646254,386,20554,4386,103,917209,9,4,836935,674368,66,77,289,2483,3,4,59509,2,21,14,36143,41140,509,310572,1246,712,38,245262,6164,2,387291,194145,330,53,357167,3,3,1,363,9631,3,34908,185,276,7,134964,332093}

    92747

    Returns: 917208.6313228682

  37. {5406,10,294,2814,575680,146,104,1,838592,272,1220,5727,275337,241691,827928,18034,327,231,221739,3782,407391,128206,130923,337482,83,6216,24918,25394,201,6,575987,7666,962549,2,79,52,4381,55547,126,74,276852,47,2630,16,4420,36024,11,63175,2375,27982}

    {4,69441,7459,10,1335,387524,3549,1,306,35,46883,14,13528,1,62306,243,382515,11897,2,19128,309557,2,349,541396,1227,5091,126063,838438,526,258,41291,1839,676,174,31,9,28,153906,3567,153,78004,69,120,33,641,32,447679,495229,2186,15130}

    144927

    Returns: 838432.2928644561

  38. {1,215,3157,24450,4817,142,669,4485,22777,42849,52807,1,4007,17,680,17126,41085,123,78101,59,128,34956,36,9660,1,77409,54,14161,7,28,307788,50194,558,13335,1,1,67671,3507,852,259614,42214,187078,6442,214,401385,4,143535,60185,2,114}

    {114,1,120,262,112,28,33217,49,13,2,59,6,117996,251820,2,12337,42,462818,541,777516,2147,313988,466,889,94946,7,145,1,7,3426,446,689,363,1,45,12,3367,1134,9,48,1127,1,1161,885857,764,17,111615,29264,7,46}

    216450

    Returns: 884845.551401869

  39. {1,11388,844208,50,764,60,43545,49,16935,269,12441,9072,171683,692,13697,212,610269,8839,1,2302,4204,115,125146,147,270622,232,25,4,6,141,6976,460,616,71,6776,103,6,63,1148,1,42,7827,112,3,168305,201,114,1185,10363,28}

    {25520,52327,150,475,269,1,189640,671,1,9,759098,1,273152,360231,346,988,35,1,88,1,300590,6590,257,740478,48451,40172,30,349,69,6,944585,280,110,32,186,1374,757,876,199,146005,376218,9,8225,7634,1,15,60,8,10445,22}

    4

    Returns: 944584.9994266054

  40. {187,229,313,49,10638,3,66666,388,1000000,1,3030,76923,579,1000000,38,1282,7142,1000000,100000,321,47619,3205,23809,500000,306,31,27,11111,9708,71428,66666,6172,8,42,23255,39,10,1000000,30,5,41,166666,1718,12500,575,2,111111,1000000,1086,1000000}

    {145,760,20842,2068,65,568276,99,35,11128,13,7172,72,7,166,704,166,7846,105149,21,1254,2,38542,128,40394,9,8,25807,266,5595,23,548046,317143,9513,104849,613,9,1,39296,189,119,4,68993,3734,6504,1648,88,33966,1,296,4711}

    46

    Returns: 568260.6666666666

  41. {65,7692,1,3,3,5,1845,333333,10204,7751,328,834,17241,3533,7042,10,10,4329,382,6666,39,1,1,21739,77,2,1000000,3412,130,23255,5780,1000000,100000,342,16393,69,2341,2061,71,2,29,125000,8928,1628,1000000,2242,62500,111111,142857,1001}

    {3,15,976002,715,190,46,4987,120421,5,1,260102,771,4871,334824,1602,530527,22988,480,1537,305,7,2,6,18596,3,125071,1,260,1,5984,70,5745,104,1126,4,102882,168,29681,381,224023,3,2,44091,3,3249,327326,273,59,36,7}

    5205

    Returns: 970796.9999999999

  42. {609,62,60,1,19,28,2,3802,626,7,1113,7,21276,13,333333,57,4,4,500000,3,9900,1000000,246,125000,40000,1,9,5,6,76,45454,32258,74,45454,17241,37037,1,2,127,5376,4807,138,3906,20,500000,1000000,24390,1133,90909,37}

    {479080,51223,59,151291,1846,10129,417140,33,10,279846,212511,8448,32,1,398,4360,16559,10,547908,2421,3697,61194,42,4297,16,10978,596,3,657823,1,395,401,7,11,5112,1608,320,2,9,285,6,154408,6,2255,269,981061,132,9,4696,59491}

    223613

    Returns: 981060.776387

  43. {5952,6,3,714,1400,659,12,102,102,34482,7936,33,1000000,22727,1066,4291,90909,89,12820,290,4,200000,62500,1727,6756,322,142857,208,250000,32,58823,1000000,166666,5,4,47619,76923,142857,29,10,27,4950,10,8196,3,268,219,1375,151,1124}

    {3564,969,94710,11595,2117,2,2,851,57,75505,11,1178,379863,83,6794,6,266158,5,361494,34563,3,1,220585,6801,94196,3,156578,13300,101,59446,70586,174729,43431,436792,25322,987970,284,665395,96,93271,4811,310584,1,133968,16,1,570383,30,1231,2525}

    31095

    Returns: 987969.3470043469

  44. {1432,125000,13513,5,981,125000,142857,3703,4,374,23,36,500000,5555,369,15873,500000,20833,9900,55555,18181,1,27777,200000,7042,2288,27027,1317,903,372,567,1,17,500000,52631,2020,8000,23,1000000,104,832,47619,500000,2,200000,15873,13513,24,58,892}

    {17,4,265373,135329,101,10874,23174,1522,249238,1145,125203,18,24,1,89,103347,566094,349,303961,293,4190,25,824757,122,9,1979,17510,321,169,368,164,37589,9,257,17477,1439,40,6058,1,3,23393,1,13,5622,2080,3531,475936,3036,26491,5}

    333333333

    Returns: 812756.664002592

  45. {316,3,3508,529,3,1000000,34482,21,1434,317,1000000,4424,18867,1000000,1000000,9345,1,31250,470,3125,218,29,76923,9259,1795,18,3,14492,9708,4329,1000000,5000,11,124,10,125000,1000000,1000000,1,61,10,52631,189,2487,2,200,20,83333,1582,1000000}

    {44906,69490,54991,25,4,276258,2,1,53,1627,56,25407,251,8220,46,612,768,43,1,56766,1,7,1148,79564,4604,1369,6366,52,12,2138,499931,433257,2515,154,1,603,599847,718991,1359,140,3,2,12,957,4,21,49,192,3968,644941}

    519182065

    Returns: 718471.8179349999

  46. {19,37037,6,40,38461,190,1228,30303,1349,321,108,24,33333,628,40,145,1033,139,2,500000,280,83333,96,2,22727,250000,10,1000000,124,2840,13,1000000,3,15,119,9259,82,166666,730,368,69,134,1,12,2,22222,333333,26,147,831}

    {65210,174519,217,38060,4696,7661,380650,14293,68,805,147126,908,31,160,5,5,17092,80,6,43457,11,11681,288737,41575,690425,21,2,1278,1,14,1,50,20,7757,73385,32794,389677,2,35,151188,2576,98,4406,3,2,2393,45693,103517,36495,8}

    33694048

    Returns: 688942.4440973292

  47. {4504,4,1000000,2,16666,2336,4,15384,9803,25,2,500000,948,40,231,250000,314,24,1000000,15,333333,11904,333,111111,1000000,2092,455,39,250000,3,239,341,2,20000,4761,2624,1000000,326,820,76923,22,6,3,7,126,27027,152,1114,12820,4}

    {1006,272812,1,355663,1,333980,2360,138803,1574,183004,99976,4312,3,25,950,613,3510,474367,416999,147886,163713,566,15986,54,425,1,226,13752,27,10,100,1881,1782,50,38905,10,28,160751,31436,2,364016,416,23,24272,12786,690456,142799,12,14977,1722}

    917407231

    Returns: 656511.8985088984

  48. {50,1101,13,1494,3906,127,250000,1000000,2,62500,505,12,10,500000,5,5524,250000,111111,219,213,10989,18867,12820,8,22,15,4,1000000,102,333333,500000,5128,200000,3,4310,5347,333333,431,11,29411,450,2,136,15,2,1000000,12658,8333,142857,244}

    {4,36,15,176277,1,3,41295,234421,12827,1430,1045,179262,141614,3707,114053,66,93,17,4998,426729,1870,785,2586,192,425,9933,1274,3620,964456,15652,2,9127,1334,1497,93753,1,1144,232,66405,142599,558329,14,19,70199,11,402779,14909,229849,145,680060}

    163

    Returns: 964454.4019607842

  49. {1,250000,30303,525,11363,83333,1000000,1398,19,545,1000000,200000,16393,250000,2652,3,1,8,151,100000,274,3484,3,12500,250000,4901,13,661,6,308,427,203,21739,333333,500000,6451,55555,71,344,280,500000,30303,5376,471,781,203,547,1000000,14285,5}

    {25,5259,10241,2,3,3222,873352,30320,26700,333027,172177,658,723333,16,24,62,4,964980,2,38347,158085,1,83,52384,40093,843,281094,2301,8,253104,356,297,67540,2102,114,15,29392,21,4,397266,969,170937,198015,8,819,30702,1,1,21395,100263}

    260620

    Returns: 932402.4999999999

  50. {55,476,2036,500000,6,88,500000,166666,1582,7407,15,21276,16129,1310,1529,4405,9803,1703,500000,47,500000,952,27777,35714,415,57,1197,44,6849,111111,8,500000,16129,12,10309,43478,10,333333,5319,250000,166666,111111,62500,26,6578,2475,2564,59,142857,28}

    {5617,200000,12345,2,1335,1512,20000,1000000,76923,115,4016,1631,1,333,213,3,1000000,40000,6,6,1000000,500000,250000,7,1000000,10,6,273,7,62500,10000,3389,63,31,3,1,8695,1000000,98,216,500000,83333,1,84,265,40,1000000,1,12987,8}

    201548680

    Returns: 999596.90264

  51. {29,1692,4,200000,6,10,120,200000,2,625,13157,1165,1,2,1000000,62500,12,130,113,3,38,1,650,1592,13888,11904,2,1937,7633,5,76923,121,25000,14492,968,41666,200000,32,803,1000000,27027,1,52631,1,200000,250000,4098,4587,34,9345}

    {31250,12345,250000,564,26,10638,45,21,500000,1096,4,4,6134,240,54,1000000,250000,19,29411,32,250000,6,2,166666,500000,839,189,109,64,73,31,49,17,30,76923,27027,30,130,90909,71,9,71428,809,12345,1,2923,1254,4,11235,9345}

    923294253

    Returns: 985227.2919519999

  52. {6993,2967,6,13333,1000000,58,500000,25,5,254,1000000,200000,17241,116,38461,99,500000,132,125000,50000,200000,1000000,4608,3,1782,324,1000000,1,250000,500000,780,37,34482,8,11904,74,27,1,181,55,6,100000,6,6944,12500,10526,154,509,39,66666}

    {594,1631,145,1000000,37037,967,83333,16,291,1047,36,529,3875,1298,43,205,1,359,4,38,83,24390,3,9,3236,2881,1347,2450,1010,4,76923,111111,90909,18867,12,14,38461,130,3344,1000000,1117,14084,71428,5,1,35714,35714,1,495,7}

    984398984

    Returns: 926168.2304057601

  53. {2493,2,142,1,12345,7812,16393,1,184,16,2481,1996,16393,500000,347,3584,9,3,500000,401,5917,136,173,33,250000,217,14,209,16,22727,501,4424,424,57,4,494,33,333333,219,16,30,333333,38,2,3389,34482,2,38461,25,10}

    {1879,240,5050,142857,4,1000000,193,1000000,6535,22727,23255,8000,133,152,9,10,250000,1277,83333,2,4,333333,1529,121,31,1,500000,23,454,36,250000,1000000,1597,66666,55555,513,9345,186,16949,3300,62500,1305,1,1,904,1,2150,989,3571,1000000}

    58941261

    Returns: 992455.0357142857

  54. {2,1626,4,142857,1000000,19,35,15,1650,18867,35714,415,1,1248,2,1000000,6024,76,307,28571,200,1,1,500000,1785,219,777,18,1000000,1000000,47619,24,34482,8,8,3521,454,2531,4,2506,2,571,63,1000000,51,125000,333333,200000,3144,563}

    {71428,4975,19,1335,1000000,14,1000000,3,88,20000,45,12,31,31,166666,27027,105,2,16666,2,30303,402,1000000,24,7874,111,142857,14492,12,13,16393,339,122,40000,100000,1,1000000,519,91,255,333333,2,500000,16949,125,11627,3906,1086,18181,1197}

    123843540

    Returns: 999876.15646

  55. {1, 1, 10, 1, 1 }

    {3, 2, 1, 2, 3 }

    1

    Returns: 1.9999999999999998

  56. {1000000 }

    {1000000 }

    500000000

    Returns: 999499.9999999999

  57. {1000000 }

    {1000000 }

    1

    Returns: 999999.999999

  58. {1, 1, 1 }

    {30, 20, 30 }

    5

    Returns: 24.999999999999996

  59. {65536 }

    {65536 }

    1

    Returns: 65535.999984741204

  60. {999993, 999991, 999997, 999992, 1000000, 999998, 999996, 999992, 999997, 999991, 1000000, 999995, 999998, 999998, 999993, 999997, 999993, 999991, 1000000, 999998, 999997, 999991, 999991, 999993, 1000000, 999997, 999991, 999992, 999994, 999995, 999993, 999994, 999998, 999993, 1000000, 999997, 999991, 999991, 999991, 999999, 999993, 999998, 999997, 999994, 999995, 999995, 999992, 999999, 999996, 999993 }

    {999993, 999991, 999997, 999992, 1000000, 999998, 999996, 999992, 999997, 999991, 1000000, 999995, 999998, 999998, 999993, 999997, 999993, 999991, 1000000, 999998, 999997, 999991, 999991, 999993, 1000000, 999997, 999991, 999992, 999994, 999995, 999993, 999994, 999998, 999993, 1000000, 999997, 999991, 999991, 999991, 999999, 999993, 999998, 999997, 999994, 999995, 999995, 999992, 999999, 999996, 999993 }

    500000

    Returns: 999999.4999999999

  61. {5, 100, 5 }

    {100, 1, 100 }

    400

    Returns: 19.99999999999999

  62. {1, 1, 1, 1 }

    {1, 1000, 1, 1000 }

    500

    Returns: 500.3333333333333

  63. {1000, 1000, 1000 }

    {100, 1, 100 }

    1200

    Returns: 98.8

  64. {10, 10, 10 }

    {4, 2, 4 }

    10

    Returns: 2.9999999999999996

  65. {1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000 }

    {19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 }

    994382195

    Returns: 0.0

  66. {1000000 }

    {1000000 }

    100

    Returns: 999999.9998999999

  67. {1000000 }

    {1000000 }

    1000000000

    Returns: 998999.9999999999

  68. {469280, 843409, 956220, 435726, 379004, 178003, 643990, 212646, 812720, 478079, 195180, 281467, 477324, 205492, 80889, 666505, 66145, 911828, 485002, 630687, 52008, 516789, 370184, 819076, 661125, 892316, 55715, 96337, 720742, 494546, 764886, 528772, 587237, 203565, 986147, 179628, 956494, 539191, 665350, 976684, 751869, 288356, 79223, 674334, 736566, 649045, 217470 }

    {46349, 59789, 21343, 1117, 79436, 21995, 86802, 40692, 7141, 46475, 10444, 84263, 58024, 16668, 37002, 82615, 80014, 93244, 406, 86477, 99063, 49342, 53645, 27867, 93535, 15162, 76056, 72935, 41830, 73218, 4691, 32951, 21538, 24850, 33832, 98531, 2132, 94400, 26191, 3551, 8237, 30550, 40292, 99440, 56939, 34894, 52529 }

    526912275

    Returns: 98658.61825890433

  69. {1000000 }

    {1000000 }

    994382195

    Returns: 999005.6178049999

  70. {9000, 3 }

    {1000000, 1000000 }

    1000000000

    Returns: 888925.9135843607

  71. {1, 1, 1 }

    {3, 1, 3 }

    1

    Returns: 1.9999999999999998

  72. {1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000 }

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

    1000000000

    Returns: 0.0

  73. {10, 10, 10, 10 }

    {10, 1, 10, 11 }

    12

    Returns: 9.899999999999999

  74. {1000000 }

    {1000000 }

    10000

    Returns: 999999.99

  75. {1, 1000000, 1 }

    {1000000, 1, 1000000 }

    1000000

    Returns: 1.999996000008

  76. {1000000 }

    {1000000 }

    213

    Returns: 999999.9997869999

  77. {1, 10, 1 }

    {120, 1, 500 }

    500

    Returns: 10.833333333333332

  78. {1, 1, 3 }

    {3, 1, 3 }

    3

    Returns: 1.9999999999999998

  79. {1, 1, 1, 1 }

    {200, 250, 150, 250 }

    50

    Returns: 199.99999999999997

  80. {1, 98, 1 }

    {100, 1, 100 }

    100

    Returns: 1.9799999999999998

  81. {65536 }

    {65536 }

    123456

    Returns: 65534.11621093749

  82. {1, 1, 1, 1, 1, 1 }

    {1, 1, 10, 10, 100, 100 }

    50

    Returns: 74.99999999999999

  83. {1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000 }

    {1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000 }

    1000000000

    Returns: 999979.9999999999

  84. {3, 100, 3 }

    {3, 1, 3 }

    2

    Returns: 2.333333333333333

  85. {1, 1, 1 }

    {10, 5, 10 }

    4

    Returns: 6.999999999999999

  86. {1, 10, 1 }

    {10, 1, 10 }

    10

    Returns: 1.6666666666666665

  87. {502, 4196, 405, 4299, 1124, 6883, 1567, 338, 3145, 4898 }

    {6518, 106, 9452, 2189, 9506, 6753, 6717, 4439, 1502, 3872 }

    55829

    Returns: 9456.330071174376

  88. {10, 10, 10 }

    {1, 1, 5 }

    10

    Returns: 3.9999999999999996

  89. {123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456 }

    {123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456, 123456 }

    1000000000

    Returns: 123293.99896319336

  90. {945030, 811436, 201804, 413003, 538715, 546272, 963339, 29115, 598776, 420774, 193549, 314789, 122999, 587351, 756820, 988063, 234901, 755181, 352143, 355790, 973130, 664091, 768758, 640505, 795299, 211430, 15519, 321703, 54294, 90811, 268248, 607219, 392414, 693642, 51006, 558117, 216401, 993753, 275157, 742540, 360119, 210084, 279008, 809490, 479205, 24683, 153914, 910680, 200849, 420628 }

    {693741, 128331, 5038, 337596, 484170, 195262, 978242, 550096, 240643, 90177, 128447, 244328, 437054, 538361, 852504, 684702, 557874, 179192, 559454, 488676, 474430, 664408, 312786, 85468, 529535, 619788, 443524, 120372, 222250, 262014, 167139, 883513, 295970, 458663, 893598, 798514, 617684, 869732, 143412, 471353, 487753, 232333, 170959, 950863, 401219, 852051, 828319, 70005, 902035, 778385 }

    426661337

    Returns: 977799.1015634163


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: