Statistics

Problem Statement for "SellingProducts"

Problem Statement

You are planning to release a new product on the market and you want to find a strategy that will maximize your profit. That strategy will include fixing the optimal price for the product. You have made a customer list containing the maximum price each potential customer is willing to pay. You also know how much it costs to deliver the product to each of those customers. You are responsible for paying all the shipping costs, so if it's too expensive to deliver the product to a customer, you can choose not to sell to that customer.

You will be given int[]s price and cost, where price[i] is the maximum price customer i is willing to pay for the product and cost[i] is the cost of delivering the product to customer i. Return the price for the product that maximizes profit. If there are multiple such prices, return the smallest among them. If it's impossible to achieve a positive profit, return 0.

Definition

Class:
SellingProducts
Method:
optimalPrice
Parameters:
int[], int[]
Returns:
int
Method signature:
int optimalPrice(int[] price, int[] cost)
(be sure your method is public)

Constraints

  • price will contain between 1 and 50 elements, inclusive.
  • Each element of price will be between 1 and 10^6, inclusive.
  • cost will contain the same number of elements as price.
  • Each element of cost will be between 0 and 10^6, inclusive.

Examples

  1. {13,22,35}

    {0,0,0}

    Returns: 22

    If we sell the product at 13 then all three would buy it.(3x13=39) If we sell the product at 22 then only two would buy it. (2x22=44) If we sell the product at 35 then only one would buy it. (1x35=35) So, 22 is the optimal price for our product.

  2. {13,22,35}

    {5,15,30}

    Returns: 13

    If we sell the product at 13 then all three would buy it, but we would only sell to the first one.(13-5=8) If we sell the product at 22 then only two would buy it, but we would only sell to the second one.(22-15=7). If we sell the product at 35 then only one would buy it. (35-30=5) So, 13 is the optimal price for our product.

  3. {13,22,35}

    {15,30,40}

    Returns: 0

    Here it is too expensive to sell to anyone. So the optimal price is 0.

  4. {10,10,20,20,5}

    {1,5,11,15,0}

    Returns: 10

    If we sell the product at 10 we gain 9 from the first customer and 5 from the second one(Total profit = 14). If we sell the product at 20 we gain 9 from the third customer and 5 from the fourth one(Total profit = 14). So both 10 and 20 are optimal prices but we must choose the smallest one.

  5. {13,17,14,30,19,17,55,16}

    {12,1,5,10,3,2,40,19}

    Returns: 17

  6. {4,9,4,2,2}

    {8,0,0,6,2}

    Returns: 9

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

    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

    Returns: 1000000

  8. {467293,358484,827680,435564,382129,726324,298368,333351,868294,859686,34874,942224,728480,548236,840210,438682,82811,658065,385348,829507,289175,573376,724025,337450,908264,946084,590862,536924,349689,20752,733772,787227,483159,513496,248919,8620,484898,503134,796218,157463,179152,887341,55056,432994,997441,476335,509403,788854,284906,931337}

    {166214,109881,354022,339321,227020,663828,196547,106519,388609,480446,11258,196693,335701,288858,517228,228904,742,473396,275692,737682,170767,172934,36341,245983,729412,138480,144401,363441,267621,13492,21474,116055,479128,226755,215419,4022,215803,211286,524844,87053,112047,94218,5446,389390,690167,386352,310767,176841,113475,119247}

    Returns: 724025

  9. {904795,387026,429038,621091,585174,100975,615344,761417,13979,983500,72033,507926,728778,78911,330061,541048,669817,324430,154189,101495,189846,34282,255113,562426,2091,409474,242046,335239,854157,703578,304627,114421,967306,679524,56129,273573,50443,499374,626573,690107,325311,313879,87728,409424,355547,98031,584830,195611,11977,977539}

    {310420,275381,289102,92995,290939,99132,569572,409224,3614,853902,54318,6472,526302,1700,125364,214725,479897,208846,123112,39569,97935,20059,250777,72205,470,65802,79193,101010,184875,357846,35693,107312,435002,96957,47422,10384,23479,16808,496305,604665,193253,282590,1759,23559,167594,47802,70530,131426,10279,191658}

    Returns: 499374

  10. {310705,173005,702553,287205,335748,104156,543902,411464,82930,154939,493581,857422,160199,305681,418483,343183,446844,335636,718991,853089,87590,577268,797753,94547,582837,987617,692312,580317,589760,250879,511665,41477,59471,651320,646350,328714,831799,297777,5996,390148,665777,187642,419963,288760,488490,153834,691881,917614,924258,61543}

    {139363,121111,413123,116610,172374,51847,37518,155048,50078,150668,72718,408512,91795,5393,301089,18223,200209,24778,380083,757660,69555,548494,224033,11761,164184,648562,586065,350687,83595,196616,14656,25681,47894,388496,351074,306632,425499,262254,3434,33585,78028,82418,48092,98245,371807,60726,55130,245129,230607,31736}

    Returns: 488490

  11. {603875,216153,220035,500054,793572,724531,897981,7609,599878,430889,444382,991458,321402,229627,584934,781473,179044,252396,800867,263880,707055,253905,911167,689308,668959,850939,671027,198120,949934,644711,75549,450678,523576,655894,773878,408913,674886,161884,178978,398677,624052,265836,765308,79916,102813,452849,599214,927097,14077,120382}

    {591991,443889,579916,906579,770798,587746,569253,311106,178865,169759,646510,758444,148407,7905,662700,73065,787007,222692,838841,374393,809822,390961,894289,716049,768959,427118,223893,498945,761190,301931,688418,834297,625187,270144,662449,609710,147868,22657,102137,47825,445377,175455,483864,966080,227521,308711,815605,751818,505979,876484}

    Returns: 599878

  12. {511598,858102,167675,651767,427735,990621,231261,296937,527340,182837,301344,400565,701247,598297,134064,258752,153804,986749,140983,83091,948725,146474,57384,35874,957007,961181,693047,308881,889531,356177,32844,145649,976604,906489,564366,642430,49191,231967,722902,108226,857661,400709,795598,910050,898489,974096,95915,259496,530792,158123}

    {294728,669658,715962,244287,382175,972671,616817,696882,402859,631279,421681,104959,417452,116487,483346,98469,153183,546360,232360,604635,270973,982960,614853,826278,19252,269509,983591,409455,619555,345567,256332,688461,949418,211886,10499,658927,54895,980728,295462,496986,721529,787276,217128,717215,312104,501097,99378,351029,164538,299245}

    Returns: 857661

  13. {951769}

    {0}

    Returns: 951769

  14. {1426,6}

    {82333,238478}

    Returns: 0

  15. {54167,5563,9}

    {546091,35,6}

    Returns: 5563

  16. {1,74,2037,61012}

    {2,730841,484,548}

    Returns: 61012

  17. {8460,91033,8976,6,8}

    {7,29,138,3257,17}

    Returns: 91033

  18. {2040,97,9076,842268,3,4120}

    {1201,4339,115804,441226,33,20}

    Returns: 842268

  19. {62249,225020,44,58879,27,5047,934}

    {99081,555,594,704983,33218,1,77188}

    Returns: 225020

  20. {897316,496362,7575,10,68573,2,267670,9784}

    {26989,3964,38,2,364,0,3,526}

    Returns: 496362

  21. {66,60,37100,3,57,85985,838713,9,34468}

    {65,8,213507,907,167127,5512,60344,89017,79}

    Returns: 838713

  22. {85324,4,17999,21499,5,6233,1,54792,32,31905}

    {1551,9852,93188,7,3,6187,5339,2491,767,8}

    Returns: 54792

  23. {5896,8,904387,39456,4450,639713,90998,227027,9,576,6}

    {8735,214,9,658917,23773,693,9,935425,947960,527,48028}

    Returns: 639713

  24. {42798,4984,178887,33578,165782,15118,686169,61452,923443,931478,943,405}

    {13661,755,7,34,1,4,328427,149998,241,621,41734,952}

    Returns: 923443

  25. {36,400,95,1,9,1033,7,1,22750,17,9,2716,136}

    {48591,2455,65,0,2,1364,643,27,76,3365,175,4943,75390}

    Returns: 22750

  26. {3,704,8408,96,62,2066,1,84196,10,133037,33535,8,60,6}

    {962104,919,868,15,60528,4,10783,51,3036,412219,4,522,938,92}

    Returns: 84196

  27. {58,10,3067,74,47848,491,740,8975,15601,91,895,29331,4,5506,5575}

    {1,3,968,799918,6,93,32,94,94622,16,7,3753,75092,7614,54013}

    Returns: 29331

  28. {44407,5587,771,33,10,902,81,645,805,8,70215,70718,9385,304215,7,59157}

    {6,66356,7,5300,930,802,8247,271642,287,575,958,1888,1166,27,468,39}

    Returns: 304215

  29. {329,684,447,6,69461,51004,9303,6,6125,338,54,382,7,1099,679,162848,8}

    {3487,3,449,12281,81984,60068,69,41176,697,26040,297,6381,60,70,501,763,933}

    Returns: 162848

  30. {4175,672,745,93,38220,396,2,411,39,135,639031,84,151036,69,9,6271,10,7}

    {8,537552,59746,387818,31,58,940,70465,103110,3,34126,55,273,5,2,58439,43,3}

    Returns: 639031

  31. {76,73,657714,935,8,91715,3527,8,2,96,4638,54963,13872,53194,86175,4,78,2,715}

    {9,9,69,39,735114,0,90144,11416,600368,8690,423775,760,1445,925,92396,9330,193189,7711,41}

    Returns: 657714

  32. {355,705,993,44822,62716,77,6,36,49,7,8,681,1967,5,8,17,6900,174,6,820229}

    {77,4554,33142,3715,20,3,979,30,6178,43,8,2110,313,258265,68618,4,31187,9,79,224688}

    Returns: 820229

  33. {67327,250,434178,90999,366,935016,5260,27,1,238123,2,89,519,38460,289149,295,685730,6,154,342134,2}

    {176445,356387,55,6059,530,3,77377,5,37,97,5,29,369,676593,506,8,146208,5343,855,10,8082}

    Returns: 289149

  34. {34266,543,830,8,689,7149,8,848,6,828,6,4,1332,6,48,2049,836,308,28,132445,29,1}

    {572,3111,16733,108,10,86,7,0,3,8,56,310,3,51819,916,68414,6,620,328,84525,63,4}

    Returns: 132445

  35. {435151,795629,755,20,2,56,36,61228,95,1833,80,309138,269696,5,8,504,14410,654,56801,94,530,2,9404}

    {40781,3,909,407168,190999,391,28246,15640,993,4519,926944,53113,47754,305,0,157,87,9909,5,66,46959,0,22612}

    Returns: 269696

  36. {1,293368,2563,4,64329,824559,3738,8,349876,791362,1222,4,733766,5,767,453,2,19203,20,6,9369,47957,255,59100}

    {92293,50465,84350,138,9,8855,16470,6,222,169612,350,9973,38,843913,60,693,63591,3913,1460,354877,6896,45,14285,1444}

    Returns: 733766

  37. {183,8035,83,5190,997,4428,7,50,4520,1969,8766,85,82958,3891,458173,74535,733879,190965,410,2348,1306,469,197,23,7139}

    {682,32,555186,6,983614,59387,90006,2391,8950,6,42,62,13,46,28765,8025,753,5,520,95233,3170,826228,5497,793397,7423}

    Returns: 458173

  38. {830814,4,10123,633276,1,306684,37,224661,37,380,40,3,1907,836,733,7,566,3056,138722,7561,897,247379,82790,9334,54,4}

    {64238,9,903849,44863,57,0,403,3483,2573,715964,805,8,8,222,3778,72159,718,2416,670436,9066,60,71833,87905,716752,59717,760580}

    Returns: 633276

  39. {2,847,904080,14,58,5702,835,14579,21650,58,5946,75,3,9243,714,748729,523134,19984,225,46,647410,468,6,5,2,14,6}

    {8,26,4,5005,9298,85235,22,6,810,53,287017,725,4226,3401,4,5264,68,64735,584,6396,9,8145,91464,7,93677,4360,96}

    Returns: 523134

  40. {282,76,44,53,993,9,64,10,31,720802,44,2,77284,4004,8,81513,99278,4796,8693,17944,1,1311,864,36,500513,743257,560,169}

    {47804,2462,68432,69940,6,97122,31042,83727,312,4,831301,602,0,7,48,129,913884,30,62,1547,8,681,256,5,3,809,6,66607}

    Returns: 500513

  41. {72,80,2,10,3290,31455,2,100,412,8901,573581,6774,46754,14297,492,1027,4849,34,22045,4890,503,5,34426,20,811,499,27931,22,3294}

    {788832,751765,678552,56652,250,94427,11802,18,610039,15193,8617,3,226,764,9,29565,98,240058,6,58863,44964,2,31,4551,5,39313,922,87,25}

    Returns: 573581

  42. {19,1,64868,20,3288,256288,280144,10,9809,55126,3,297,94,8829,95,711031,469580,790634,2959,18,8,9,213376,973448,90,5,6885,85295,696740,6}

    {630,6,1437,3,65970,79,64,92086,8,790,2,24207,48,895938,7,90672,111,48,944,369100,22,68863,25817,836972,2063,25,30181,212086,4,1288}

    Returns: 696740

  43. {38,587,533633,112831,804,639,6,8292,64437,10,352,736450,2318,1,74456,4,6,56,3,43,2007,4498,4,9,593231,4,2818,825,5642,931107,2}

    {36737,6,6,72170,458,8,8059,882914,31,94,91,315990,743002,542,29317,9154,9382,46280,9213,309,48,6,365881,690733,71589,6,320,57319,212,5189,42269}

    Returns: 533633

  44. {70131,60,87187,377326,4,94,4,61952,422,1,169429,93117,8168,8690,89,950,852276,777619,86,7853,24,48166,70,258,213595,751,83993,849586,41597,686744,44876,506234}

    {2635,2,231895,48,64,960863,826,89574,76,40,259415,14,888939,798,6406,7213,181084,47071,640517,31630,6461,763240,30720,50,828,9541,9428,654,91,3087,964300,727}

    Returns: 686744

  45. {8818,47,11,69695,5763,49953,2,892421,405,757110,977,5,429,462483,337199,660,7086,512841,9,921946,96561,3812,8281,3,8,3,668,61,346,608,886,34,9}

    {85,4501,8,33,85891,799029,5,208250,130061,7,540,599,8973,0,26,9951,758714,3,4790,2550,0,88,2,75511,41462,88,7,946,32414,77,35,12,809201}

    Returns: 462483

  46. {6655,12485,33939,664604,899349,823,6667,9,193,3172,6172,73915,4390,458,16,491,66762,695329,40578,40819,972,374,55512,9,508589,3,691988,712,294960,481,842,138274,325,1}

    {816,507,37488,553635,488,72155,285891,39,6858,709,484,1814,166,25,128,554851,94228,744,25745,1604,3035,1442,5063,649,73,25,7806,9,48,817,4330,3,9697,1474}

    Returns: 664604

  47. {4,2253,81767,2125,958403,461272,85,3318,197888,121782,10,59,279,82772,62426,8,4597,3747,57193,436,7233,4013,12259,285211,21013,8,66,796823,7682,7,9982,68483,914,479259,459}

    {1,657058,14399,16599,208666,7,55156,397,37,8,971,0,2137,53,2,4340,60,3,7544,0,57,8527,8,255,77,815,440,119,46,4284,764,25,16853,82300,81}

    Returns: 461272

  48. {2770,8560,24,726,67443,276,281,19,388,6,21619,968082,2889,57,8674,8195,616437,1176,7,97,43,236,11,310,144,10,646795,956,121801,2603,670,3,728660,52997,54145,25535}

    {9471,898,55492,21026,80427,815480,667316,435655,586229,84,62,222219,6528,8588,24,4905,87,35,796,892537,402,3886,980,339,554,526482,1414,30,96,725,461312,850503,94,9,6,89}

    Returns: 616437

  49. {3,313287,87225,44,532,4907,44,67,8747,96441,444,51941,169,3718,9,527770,4,3618,419,10,9544,80300,4,67,2,5,33511,295035,6689,9253,45,72307,952,43706,83,559161,920654}

    {18205,605973,632,671,82,78,4596,92,263081,517567,11,71608,757,12,216,4,1,68589,3,48,67013,3698,8,16,7518,136768,80828,674898,42315,4,9,5829,24,84,4178,4,122}

    Returns: 527770

  50. {503,34538,2648,3625,12,11,1172,721918,5812,4,73771,562,71107,40799,7261,638363,859,556823,67,2745,304,528558,773287,69824,66,9,45,8,79,624535,8889,8,18,5,43,42,58,92}

    {5,210,295,33322,701,29418,8779,474,542313,7244,96,7,110316,528,8110,3,1032,29,494564,381503,698635,106630,357308,83004,7227,89,4,1281,64902,235,2804,759,94949,5,95670,1618,2258,17}

    Returns: 528558

  51. {7,7431,33,89,9316,41,8296,661936,58020,742557,10,55002,7485,55107,2,8407,26711,9019,60,47957,1,9816,96576,54163,71,5962,9195,11736,488494,81475,946103,707,838,27413,733673,527,370,28,6}

    {21,1,2,26079,7,9,4971,631,9513,47270,83563,30316,5862,6,7,7,7407,498,65,56014,82,53054,230,999439,6412,661933,481331,87,4,38166,1676,49,3566,953,2248,55528,740052,12,109}

    Returns: 661936

  52. {145,271,7,5442,888,817813,47309,1,223,405968,74,181032,1079,730,603767,4,45,6,825,178896,520,46182,947,933,6,6,182,77,486,101,949420,4,60687,2813,91694,66,2469,8,279787,643}

    {964472,3,4706,669,29,1702,2,37,3,69,263,372198,252,54932,8396,17012,24507,256621,6,0,350158,4999,1,830,25225,407,9443,7,3838,183933,74216,65,465,240940,524634,50946,7719,7831,63600,92}

    Returns: 603767

  53. {35941,4,50,686417,8,7828,73,38,1135,315,18,518126,75458,9270,24502,6,126,2165,6,485,6,196645,6,4,52534,9,1,2,91534,1353,9440,565,5,612283,5078,299267,444,7024,2,286,237}

    {21096,268408,5945,19625,98820,856578,3021,8,676501,42,420411,389308,4522,2,68,50345,8443,71463,5646,106,733,4272,699768,34543,53604,28585,12,620606,1,91,4871,0,5851,889,836,482,63906,5713,62,4,4}

    Returns: 612283

  54. {3857,9,685676,28,5288,18722,120,356135,805,65357,5,4021,9692,2,63682,3,9,4,469018,226924,679,1,8,259660,6,857752,10374,2483,984,327,581481,81824,79976,461,28281,63922,8,655630,89,3034,72214,91}

    {40,3,4,1,26785,99,729308,284818,12951,801,53,74837,97106,2172,9482,41,5592,86,288838,4179,0,780,648,1,991796,742,544,945,2947,34,47,903823,90994,40334,1964,864,673,0,632,651617,139437,363729}

    Returns: 581481

  55. {39,715,394,132950,466022,392444,292220,4588,819,687973,32,5,32487,47515,8792,79778,5010,548324,37101,9,4673,498574,8982,7551,952761,9,358563,8,33,9732,509,850,876449,5573,8,84430,477,35895,997,3,26827,4298,658}

    {5600,2,5,757,52318,8,3,872,2586,1,48630,992798,78,445006,22610,93357,6086,85458,95868,8,91,7089,6,737,69530,357106,66850,33521,749,232096,5243,4,0,5515,95723,80,5558,4,3,79219,33,8381,79424}

    Returns: 358563

  56. {6793,144,335,23917,6,3,836941,33,86,368117,381,600116,63979,5,237465,5,446,327,69,607857,92443,739005,70908,548656,35,229,420,898452,45366,1682,636358,189,990,833101,9,7722,102,3,53692,69,828346,476,345644,71020}

    {262266,2,1892,53,78440,407,830,2,143,7,1408,2,8699,4075,438135,7,72,18727,6,10819,890856,2241,17,8,719056,756,10,47868,3260,698,43716,2265,4903,14974,4,66,980,86244,48069,1,415289,918024,3852,405}

    Returns: 548656

  57. {898,3761,267,637125,667,701,88954,13402,607302,300,37,3,3,65490,9,4660,9,75,4,9538,128,847904,4841,2,7,95887,3,6552,4342,32322,5,9,714853,84521,60469,6,7,319,10,6567,853337,3363,208,3601,411}

    {38,167100,92675,108078,2,632,4,273,20,379367,408,0,117,7204,996972,992825,291,2969,3,75863,6834,590865,5260,76160,73725,19195,199707,27832,10,7,2,7,1800,830371,1296,73056,4705,88413,19,6,9573,55576,2,43722,694957}

    Returns: 607302

  58. {57,70,2373,639263,421,160,40,845,9189,806,674,4797,482858,593839,63,3,68533,8374,257,244,42520,14777,82,313,92,7,4526,10,96974,8,2820,873,1,8,83,38294,702269,684739,634245,908800,579,906987,3,79,4,6}

    {314013,9,846093,1,69,63785,0,949343,8,6,1323,31,9284,45,609394,706,322570,516494,31,32,25,8,19,509343,41,185,3,58407,626,316,10633,862750,331,693832,2223,29,7687,8888,653,20262,39899,82,630002,3,854049,84}

    Returns: 593839

  59. {89,248079,3,746102,23813,99404,19581,829150,97428,3,10,836425,675,52849,919024,662,6,933,9,2,839,80,725213,314,978982,70,5929,917,45,759728,7112,50924,97,187,2,86783,1,99,10,7674,5534,32,893,723722,84,839,4252}

    {30296,74,1,6140,1,8,9045,1233,49,7254,4182,5,816,461238,31704,84630,97,430,18,5,147670,1,4279,3,56199,721136,253976,889498,4,3,665,247921,764,0,3570,0,59,54,47959,0,612758,214100,627943,477,181,173782,620170}

    Returns: 723722

  60. {7,4,325,588952,3638,50572,343,5398,865254,266821,22220,52,954363,31,485,201406,893313,91599,8,72,5582,3963,272,699,91170,841994,127,5,28,814141,738,1242,88,88658,355,10,31,868,694,195101,193642,939274,12,658,70,46712,12,313}

    {1,42,1,36692,3,72,68,593,87848,9837,20,51568,14829,4883,148,3788,91,5557,4,98873,6517,0,866853,2484,553,215078,426737,557725,6821,9,29,187623,12,68,85,951252,917,2706,7333,632,33,8323,791,23,16603,4,848569,53939}

    Returns: 814141

  61. {425104,398692,8671,10,62328,5,729162,18,33,230,95,87,531989,106901,1201,67978,364,22688,876,2,73443,4462,463739,9972,969632,503414,97783,162803,3723,9162,67983,606,4700,4,56275,25282,610160,22,90747,400,741,7558,2,99434,2346,466138,2,1403,7426}

    {484,30,504,926,991,75,73,1,5224,197002,63,175,320,58347,1,421,3,613420,217,11990,538,50,5,101297,70,33,275,46,40,8,6,59676,11,51,8,521801,234,772,3520,5,32101,2183,259026,9,6,6704,58,12714,3857}

    Returns: 398692

  62. {8,377,899548,90970,840384,60900,1,24399,257068,724223,33213,44,82,832,352,33903,3,6255,73746,9,206548,409,5839,58989,23767,787,281,37124,12,2,692,7780,86536,8672,47,7127,2461,395593,46,233072,701737,210443,344629,97,805195,8,4264,4,799,4124}

    {4,40487,271,497416,2332,89592,4395,337,195,2,7,98652,890,483,3,7,1,650,11409,1846,639964,67,3476,1,2,769865,20,3637,16,281884,64,63,27605,93,872,552279,3,9877,9610,341,46,32361,58187,935,686079,859968,237059,119515,521,808975}

    Returns: 701737

  63. {10, 10, 20, 20, 5 }

    {1, 5, 11, 15, 0 }

    Returns: 10

  64. {13, 22, 35 }

    {0, 0, 0 }

    Returns: 22

  65. {4, 2 }

    {2, 0 }

    Returns: 2

  66. {30, 15 }

    {20, 5 }

    Returns: 15

  67. {50, 10, 10, 10, 25 }

    {0, 0, 0, 0, 0 }

    Returns: 10

  68. {20, 10, 10, 20, 5 }

    {11, 1, 5, 15, 0 }

    Returns: 10

  69. {1000000, 1000000, 1000000, 1, 2 }

    {1000000, 1000000, 999999, 0, 1 }

    Returns: 1

  70. {30, 20 }

    {10, 10 }

    Returns: 20

  71. {20, 20, 10, 10, 5 }

    {11, 15, 1, 5, 0 }

    Returns: 10

  72. {20, 9 }

    {12, 1 }

    Returns: 9

  73. {20, 10 }

    {15, 5 }

    Returns: 10

  74. {5, 3 }

    {0, 1 }

    Returns: 3

  75. {999999, 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 }

    {999950, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }

    Returns: 999999

  76. {8, 6, 4 }

    {7, 5, 3 }

    Returns: 4

  77. {50, 25 }

    {30, 5 }

    Returns: 25

  78. {5, 3 }

    {4, 2 }

    Returns: 3

  79. {2000 }

    {1000 }

    Returns: 2000

  80. {15, 10, 5 }

    {10, 5, 0 }

    Returns: 5

  81. {4, 2, 2, 4 }

    {0, 0, 0, 0 }

    Returns: 2

  82. {50, 25, 75 }

    {30, 5, 55 }

    Returns: 25

  83. {2, 1 }

    {1, 0 }

    Returns: 1

  84. {13, 22, 35 }

    {5, 15, 30 }

    Returns: 13

  85. {100 }

    {100 }

    Returns: 0

  86. {20, 20, 5, 10, 10 }

    {11, 15, 0, 1, 5 }

    Returns: 10

  87. {10, 5, 3 }

    {9, 4, 2 }

    Returns: 3

  88. {20, 20, 10, 10, 5 }

    {15, 11, 5, 1, 0 }

    Returns: 10

  89. {13, 22, 35, 10, 9 }

    {5, 15, 30, 0, 0 }

    Returns: 9

  90. {17, 15 }

    {15, 13 }

    Returns: 15

  91. {3, 1 }

    {2, 0 }

    Returns: 1

  92. {9, 6 }

    {6, 3 }

    Returns: 6

  93. {10, 3, 5 }

    {9, 2, 4 }

    Returns: 3

  94. {5, 20, 20, 10, 10 }

    {0, 15, 11, 5, 1 }

    Returns: 10

  95. {20, 10 }

    {10, 0 }

    Returns: 10

  96. {13 }

    {13 }

    Returns: 0

  97. {1000000 }

    {0 }

    Returns: 1000000

  98. {20, 20, 10, 10, 6 }

    {11, 15, 1, 5, 0 }

    Returns: 10

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

    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }

    Returns: 1000000

  100. {3, 2 }

    {0, 0 }

    Returns: 2

  101. {15, 8, 1 }

    {14, 7, 0 }

    Returns: 1

  102. {20, 10, 30 }

    {10, 0, 20 }

    Returns: 10

  103. {50, 60 }

    {40, 30 }

    Returns: 50

  104. {2, 1, 1 }

    {0, 0, 0 }

    Returns: 1

  105. {20, 10 }

    {0, 0 }

    Returns: 10

  106. {3, 3, 2 }

    {2, 2, 0 }

    Returns: 2

  107. {7, 5 }

    {5, 3 }

    Returns: 5

  108. {10, 1 }

    {60, 7 }

    Returns: 0

  109. {5, 3, 3 }

    {3, 2, 2 }

    Returns: 3

  110. {1 }

    {1 }

    Returns: 0

  111. {2 }

    {3 }

    Returns: 0

  112. {20, 10 }

    {11, 1 }

    Returns: 10

  113. {2, 1 }

    {0, 0 }

    Returns: 1

  114. {5, 3 }

    {3, 1 }

    Returns: 3

  115. {3, 2 }

    {2, 1 }

    Returns: 2

  116. {5, 4, 9 }

    {2, 3, 4 }

    Returns: 9

  117. {30, 20, 60 }

    {0, 0, 0 }

    Returns: 20

  118. {100, 50, 50, 50 }

    {0, 10, 10, 10 }

    Returns: 50

  119. {10, 6 }

    {0, 2 }

    Returns: 6

  120. {4, 4, 4, 3 }

    {0, 0, 0, 0 }

    Returns: 3

  121. {20, 10, 10, 20, 5 }

    {11, 5, 1, 15, 0 }

    Returns: 10

  122. {4, 5, 6 }

    {3, 3, 1 }

    Returns: 5

  123. {10, 11 }

    {1, 1 }

    Returns: 10

  124. {1, 3, 2, 4 }

    {0, 0, 0, 0 }

    Returns: 2

  125. {1000000, 1000000, 1000000, 1000000, 1000000, 1, 2 }

    {1000000, 1000000, 999999, 999999, 999999, 0, 1 }

    Returns: 1000000

  126. {3, 4, 9 }

    {2, 5, 7 }

    Returns: 9

  127. {1000000, 1000000, 1000000 }

    {10, 10, 10 }

    Returns: 1000000

  128. {2 }

    {0 }

    Returns: 2

  129. {13, 22, 35 }

    {5, 15, 20 }

    Returns: 35

  130. {59, 39, 69 }

    {50, 30, 60 }

    Returns: 39

  131. {12, 10 }

    {10, 8 }

    Returns: 10

  132. {6, 10, 20 }

    {1, 1, 30 }

    Returns: 6

  133. {10, 10, 5, 5 }

    {0, 0, 0, 0 }

    Returns: 5


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: