Statistics

Problem Statement for "CandyAddict"

Problem Statement

Alice is a candy addict! She doesn't eat any food except for candy. More precisely, the only thing she eats on any day is one piece of candy in the evening.

Alice receives an allowance of x dollars every morning. One piece of candy costs y dollars. We will follow Alice for z days. The days will be numbered 1 through z. At the beginning of day 1, Alice has no money and no candies.

Each day looks as follows:

  1. In the morning, Alice receives her allowance.
  2. At noon, Alice checks whether she has some candies. If she still has some candies, she does nothing. If she has no candies, she uses her money to buy as many candies as she currently can.
  3. In the evening, Alice eats one candy.

For the given x, y, and z, we want to calculate the amount of money Alice has left at the end of day z. (Alice may also have some candies at the end of day z. We are not interested in those.)

You are given multiple queries (x,y,z) and you have to process all of them. More precisely, you are given int[]s X, Y, and Z, each with Q elements. For each valid i, you must answer the query with x=X[i], y=Y[i], and z=Z[i]. Return a long[] with Q elements: the answers to the queries, in the same order.

Definition

Class:
CandyAddict
Method:
solve
Parameters:
int[], int[], int[]
Returns:
long[]
Method signature:
long[] solve(int[] X, int[] Y, int[] Z)
(be sure your method is public)

Constraints

  • The number of queries will be between 1 and 100, inclusive.
  • X, Y, Z will contain same number of elements.
  • Each element of X, Y and Z will be between 1 and 1,000,000,000, inclusive.
  • For each valid i, Y[i] <= X[i].

Examples

  1. {5}

    {3}

    {3}

    Returns: {6 }

    There is only one query. In this query, Alice receives 5 dollars each day, a candy costs 3 dollars, and there are 3 days. The entire process will look as follows: Day 1 morning: Alice receives 5 dollars. She now has 5 dollars and 0 candies. Day 1 noon: Alice has no candies, so she buys one. She now has 2 dollars and 1 candy. Day 1 evening: Alice eats a candy. She now has 2 dollars and 0 candies. Day 2 morning: Alice receives 5 dollars. She now has 7 dollars and 0 candies. Day 2 noon: Alice has no candies, so she buys two. She now has 1 dollar and 2 candies. Day 2 evening: Alice eats a candy. She now has 1 dollar and 1 candy. Day 3 morning: Alice receives 5 dollars. She now has 6 dollars and 1 candy. Day 3 noon: Alice still has some candies, so she does nothing. She still has 6 dollars and 1 candy. Day 3 evening: Alice eats a candy. She now has 6 dollars and 0 candies. Hence, at the end of day 3 Alice will have 6 dollars.

  2. {5,5,5,5,5}

    {3,3,3,3,3}

    {1,2,3,4,5}

    Returns: {2, 1, 6, 2, 7 }

  3. {1000000000,1000000000,1000000000,1000000000,1000000000}

    {1,2,3,999999998,999999999}

    {342568368,560496730,586947396,386937583,609483745}

    Returns: {342568367000000000, 60496729000000000, 253614062000000001, 773875166, 609483745 }

  4. {1,2,3}

    {1,2,3}

    {1,2,3}

    Returns: {0, 0, 0 }

  5. {1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000}

    {1,999999999,2,999999998,3,999999997,4,999999996,5,1000000000}

    {1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000}

    Returns: {999999999000000000, 1000000000, 499999999000000000, 1000000002, 666666666000000001, 2000000003, 749999999000000000, 2000000008, 799999999000000000, 0 }

  6. {31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623,31623}

    {31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622,31622}

    {1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000}

    Returns: {93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346, 93808346 }

  7. {31574,31575,31576,31577,31578,31579,31580,31581,31582,31583,31584,31585,31586,31587,31588,31589,31590,31591,31592,31593,31594,31595,31596,31597,31598,31599,31600,31601,31602,31603,31604,31605,31606,31607,31608,31609,31610,31611,31612,31613,31614,31615,31616,31617,31618,31619,31620,31621,31622,31623,31624,31625,31626,31627,31628,31629,31630,31631,31632,31633,31634,31635,31636,31637,31638,31639,31640,31641,31642,31643,31644,31645,31646,31647,31648,31649,31650,31651,31652,31653,31654,31655,31656,31657,31658,31659,31660,31661,31662,31663,31664,31665,31666,31667,31668,31669,31670,31671,31672,31673}

    {31573,31574,31575,31576,31577,31578,31579,31580,31581,31582,31583,31584,31585,31586,31587,31588,31589,31590,31591,31592,31593,31594,31595,31596,31597,31598,31599,31600,31601,31602,31603,31604,31605,31606,31607,31608,31609,31610,31611,31612,31613,31614,31615,31616,31617,31618,31619,31620,31621,31622,31623,31624,31625,31626,31627,31628,31629,31630,31631,31632,31633,31634,31635,31636,31637,31638,31639,31640,31641,31642,31643,31644,31645,31646,31647,31648,31649,31650,31651,31652,31653,31654,31655,31656,31657,31658,31659,31660,31661,31662,31663,31664,31665,31666,31667,31668,31669,31670,31671,31672}

    {1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000}

    Returns: {947715112, 996905748, 929461450, 920902120, 983358921, 750407488, 697094232, 606450040, 691801021, 371107634, 508094775, 52164160, 294264760, 175068438, 70805221, 40609264, 99239665, 844514020, 922065003, 787922904, 746434582, 571016668, 876305575, 571273876, 554513897, 525176854, 483514345, 410059600, 462119379, 57849574, 140019164, 876017508, 90218470, 838050856, 910931474, 594627400, 991844878, 688357010, 48603733, 447991256, 878321563, 302279020, 379113015, 133753216, 154182016, 999841910, 548164490, 881741200, 14816124, 93808346, 305970019, 25253448, 782420000, 580259728, 800085733, 358837184, 508295566, 627778160, 823688806, 230108752, 507379291, 457287096, 306370990, 201792084, 439740367, 916602232, 869773876, 854202880, 782626330, 797111496, 789479121, 367657948, 875730085, 534582278, 526465939, 619527744, 416424089, 258187300, 208440141, 193950168, 124794550, 865850348, 326761460, 677931856, 823290626, 663158880, 807038395, 671495840, 622410914, 365145238, 239201436, 220685632, 356218885, 137829818, 570912150, 934542244, 295048060, 38467130, 930988891, 972857096 }

  8. {892314287,932964157,910449437,214954110,643890236,798563055,738003421,573285048,478155934,596104778,699587789,413340746,419050015,966867064,485730421,754792141,288824107,602484549,726544904,721105430,458277225,511998071,399674588,927982142,725384387,983540390,211788018,706757531,107057750,477912167,809443043,553734266,939806483,800130034,573688709,865705615,753499250,779014527,359303473,449841814,120582048,770062869,961075764,821926059,855618549,862731001,527804462,600734593,873058464,764860737,610630607,966508718,308505368,715563106,568158073,565591411,901239662,961728958,400933365,606560760,917957649,677939696,166189471,603290788,839785306,995620157,879293484,142762014,575397410,223198991,885560206,739442610,934099597,631560113,691963996,986726668,387059508,934437610,991390061,916088519,463730987,957877281,954614542,904942265,785122208,292076051,572622343,775494905,755218232,886814967,71055448,956569566,863932958,596020547,926893020,745181246,627876334,443315955,980243332,522054562}

    {389736837,59380716,602841311,144294055,32051709,373805363,541352951,521871057,25400283,429728966,84808407,291221863,230091123,208642106,332629974,620057552,146193270,165099777,334773024,371099570,344992218,86859026,202612029,373793014,24521941,740098069,162920072,550995393,19832808,206345777,242189128,467565763,828443455,535501933,484896772,165684170,673429759,649562702,24111682,272277524,57665564,290052366,388615697,539900934,19415513,234559521,325195953,374060522,235917863,656182708,206287568,488327591,163864877,190290444,468132840,543731707,779678966,889016841,205906320,44545852,773515186,22927817,160400457,360506368,589579816,898434122,792843708,31736608,216307993,98544605,617558486,399317836,712443523,582369398,634992733,812155222,184581225,351672587,278293336,20726691,254008533,934424948,95069144,335920602,35087415,181262002,439000820,617803233,545784841,292868301,68939529,228899296,776861373,432007179,67641115,322831358,383953365,273381806,299280789,237177906}

    {230567922,3919002,898432969,128538656,328039179,288398590,954603507,547808803,644269315,583789697,262863487,535533200,22334961,187313610,47922085,205269550,439668268,205916095,127396315,67129349,670448203,579309961,427816921,789273946,697842470,553590925,565874838,309545398,587449810,354634354,93354823,609041632,3264935,254975777,371748198,907536605,868673596,127874751,388424872,636061686,270343529,868869557,358874372,708064945,355386691,959394471,415298226,287982038,128388130,307597439,541088296,790957674,862918814,125011555,283756062,715392950,309780364,787371449,4404107,275713345,552562180,279369769,366609829,501610192,31474014,543133593,942094307,655738988,231701807,569183282,967478269,412171867,571056463,496041561,660277226,161980708,621116886,866846390,499330528,81152910,493838105,752333872,131681366,200656545,66250161,542171629,668979717,635859875,59034739,430376278,895521249,3462172,520219256,970170384,319213859,773870033,376292117,177894403,521273154,328207051}

    Returns: {100303378772735889, 2744275834818486, 274056486518724878, 4503398311269330, 166963543625746830, 7043864731510543, 153637657048143365, 6123557057949843, 286561867950275980, 39059161140655806, 47429280354689177, 64841875237501245, 3037261159048335, 74157923612658620, 6549449714102419, 6618282547313814, 9355195419637066, 73297013575108755, 29284913763515192, 21335407722616190, 64095090640554429, 137582250836391373, 12998949284369501, 130399147112146238, 12989891282774076, 8948267902611980, 5181744932057628, 8810101164807365, 49064926970839028, 5231988928482526, 1047023664111981, 29672918672773519, 198439531295110, 62067269783230780, 15110352141793370, 363352007736981395, 46468319562711966, 2462984223049085, 80421643484711758, 39151485410893024, 11791642781744164, 391241909237798325, 110979623192341649, 143946575705232723, 158791274098611149, 531357355680229932, 63820100588543400, 48008181509667304, 24559378257972307, 9140632693735987, 136374880812683832, 353701772532401900, 9217513021263662, 64703899526872078, 9189441959383686, 15119118203257837, 22842373468011098, 22612159893378866, 678982353245895, 113000869080567000, 57367712390628518, 173832860414623098, 974052766298647, 111206037350920512, 3619393416525916, 18352644723139689, 32430726624283404, 43204110271330024, 52963198069391579, 21993955864834802, 66812521895499948, 114079739647211538, 11314190102880322, 19815641290635727, 1811724667025716, 21585001097536114, 90368869315798188, 468191179874668779, 270488646593839272, 70783756057954731, 76907923464217771, 8314661517442728, 17040523522081948, 4806285928385223, 47484308920229883, 48221300752923297, 78076790352787331, 3847452904513873, 9771237138242950, 186532573260069453, 672014710287573, 1436424303666664, 42260493186585868, 134854553152691586, 209891105597921515, 20989833255800658, 878899623368258, 746599662727877, 285040868098015623, 35149329138312106 }

  9. {999999634,999999156,999999629,999999781,999999672,999999075,999999347,999999977,999999672,999999130,999999878,999999938,999999656,999999027,999999158,999999889,999999035,999999358,999999238,999999975,999999050,999999566,999999278,999999782,999999165,999999610,999999167,999999862,999999766,999999412,999999337,999999944,999999765,999999804,999999183,999999845,999999683,999999469,999999265,999999255,999999082,999999838,999999991,999999230,999999987,999999801,999999748,999999059,999999342,999999718,999999632,999999863,999999220,999999559,999999659,999999476,999999343,999999621,999999056,999999505,999999944,999999313,999999039,999999505,999999055,999999556,999999792,999999101,999999589,999999822,999999854,999999964,999999996,999999409,999999992,999999561,999999437,999999053,999999665,999999476,999999536,999999253,999999336,999999278,999999030,999999456,999999048,999999992,999999761,999999032,999999536,999999956,999999737,999999862,999999731,999999074,999999368,999999874,999999984,999999427}

    {792957299,843468632,739675614,27150691,530274943,559963984,555021320,855605907,274260621,349026093,442828340,49970424,367468203,681302182,560960051,538103642,342728906,276408153,754682761,392430175,223555138,178095703,49871947,385808851,956623925,170973273,308512591,869424757,921939747,763105692,692647982,452804005,827975129,491452534,183270308,598654995,277843948,667996,101171951,955147093,658900290,247269948,500648995,738604315,474225238,737713476,230967760,258984987,611188299,978023236,453108901,553339092,108912210,707123829,682036741,430621825,748206687,485181679,219440594,56169452,998689501,702889093,171271766,630096995,317415889,970751306,380690667,689570,575388917,307685481,714009052,505131379,301180553,322636885,455894410,682192225,916950179,304700163,613539701,609690344,557820972,630046998,528409070,51603868,427293183,781095559,11455010,599491314,79505869,407213044,287116806,143155155,376554919,887032220,744989144,777188953,738550368,732044816,495907700,232705488}

    {999999981,999999955,999999244,999999568,999999609,999999169,999999271,999999504,999999774,999999434,999999929,999999808,999999295,999999518,999999658,999999135,999999531,999999559,999999980,999999567,999999829,999999308,999999752,999999264,999999340,999999320,999999421,999999413,999999162,999999627,999999807,999999253,999999473,999999598,999999860,999999465,999999560,999999547,999999207,999999132,999999601,999999970,999999169,999999181,999999262,999999116,999999610,999999502,999999190,999999906,999999244,999999992,999999731,999999005,999999903,999999227,999999407,999999775,999999093,999999209,999999073,999999144,999999406,999999475,999999931,999999625,999999028,999999282,999999334,999999971,999999167,999999582,999999604,999999336,999999784,999999057,999999516,999999952,999999993,999999076,999999008,999999396,999999955,999999288,999999961,999999997,999999678,999999573,999999264,999999885,999999779,999999725,999999766,999999307,999999828,999999313,999999156,999999746,999999482,999999833}

    Returns: {107628021618033215, 106647340082083252, 188838847070851982, 931897464919385949, 130633760500326703, 439080458227793907, 258557351447477277, 26495393980394502, 695508895917943221, 459913379055175916, 555427076274595642, 932479894231632824, 374135265444749120, 124319119287024524, 52768426718781902, 14391767524669141, 249966547922426655, 723377532800365414, 203149760693461274, 563257253975372400, 669278045195009670, 811178918117866420, 931780195277190657, 405553738820955049, 17425591626810350, 710786366794822856, 389079492137755763, 9273645263586226, 76630287790934973, 66967059362832636, 157313907178644085, 388692245382679927, 10657282264034791, 194255441979900310, 223700371414997440, 170048805656945955, 78180435424022980, 997756489191073199, 87066159097836310, 20087733068249019, 278730945762450652, 597146628293061040, 476451174869512539, 127779424671607860, 79372568328721774, 67985711748123444, 36609450866656760, 316970678961153737, 375960555806598369, 13841436206810744, 396373989284286396, 183085639115231320, 493682047032199850, 114947392841606969, 161423384411854736, 165806447338886252, 19510338568473554, 476761667684047654, 593968452495438052, 425861118250086885, 832504942862775, 145221884874833915, 714988256937520576, 141322384299737430, 607863830636985468, 11567609615776374, 213496573814067600, 997894176892542502, 353057457386291358, 321698651862519942, 268622616311853438, 155020963918340136, 62374570850175566, 32211974175673414, 471774283600911198, 168708621489382777, 1397441512923932, 225400794770586071, 99249471780238988, 306801645679261168, 380017909858868176, 139436513353940688, 52688891320229290, 945282474552671148, 527552739622845525, 100022285633144418, 941447076752305334, 201434924568584676, 350606973215097273, 469160424134056128, 454652479200190390, 721483489345931005, 38257493204244318, 69068768469218574, 60257376366081372, 7357721766115314, 125228869261036800, 159157747092051844, 353047283784301788, 121416062642948747 }

  10. {999999222,999999870,999999506,999999392,999999629,999999979,999999552,999999019,999999389,999999377,999999716,999999468,999999184,999999067,999999880,999999572,999999894,999999856,999999059,999999668,999999729,999999625,999999823,999999725,999999537,999999417,999999846,999999801,999999288,999999135,999999415,999999080,999999790,999999501,999999948,999999611,999999093,999999188,999999799,999999852,999999861,999999308,999999903,999999210,999999176,999999119,999999662,999999928,999999262,999999230,999999781,999999246,999999376,999999130,999999030,999999310,999999176,999999115,999999504,999999895,999999271,999999051,999999197,999999260,999999357,999999699,999999446,999999669,999999052,999999524,999999972,999999388,999999860,999999454,999999329,999999904,999999854,999999571,999999476,999999788,999999860,999999180,999999655,999999528,999999247,999999209,999999083,999999989,999999615,999999045,999999433,999999909,999999565,999999911,999999786,999999679,999999091,999999024,999999639,999999814}

    {999998571,999999724,999998822,999998548,999999613,999999925,999998649,999998651,999998649,999999051,999999174,999998770,999999121,999998979,999999137,999999098,999999846,999998868,999998249,999998868,999999587,999999560,999999259,999998956,999998906,999999252,999999656,999999492,999998844,999998504,999999177,999998148,999999228,999998510,999999000,999999336,999998245,999998968,999999113,999999538,999998958,999998800,999999484,999998865,999998756,999998521,999999348,999999699,999999079,999998292,999999579,999998927,999999049,999998275,999998187,999999178,999998478,999998568,999998645,999999354,999998286,999998909,999998411,999999061,999998572,999998893,999998913,999999283,999998250,999998938,999999663,999998638,999998930,999998684,999998617,999999703,999999476,999998646,999999079,999999107,999999061,999998843,999999147,999998617,999998710,999998523,999998624,999999261,999999193,999998523,999998760,999998952,999999390,999999202,999999612,999999556,999998362,999998515,999999320,999999011}

    {999999980,999999507,999999781,999999480,999999485,999999573,999999150,999999933,999999017,999999763,999999063,999999729,999999849,999999373,999999849,999999575,999999598,999999268,999999724,999999998,999999137,999999546,999999097,999999712,999999171,999999782,999999650,999999486,999999397,999999939,999999911,999999768,999999456,999999457,999999026,999999840,999999645,999999306,999999459,999999191,999999557,999999853,999999940,999999117,999999385,999999293,999999013,999999213,999999330,999999346,999999784,999999350,999999568,999999149,999999853,999999554,999999878,999999808,999999910,999999465,999999580,999999075,999999403,999999397,999999715,999999431,999999086,999999559,999999324,999999197,999999383,999999872,999999640,999999966,999999792,999999401,999999656,999999964,999999393,999999994,999999972,999999959,999999756,999999661,999999095,999999664,999999593,999999210,999999025,999999609,999999994,999999660,999999187,999999905,999999303,999999690,999999725,999999803,999999425,999999382}

    Returns: {574000097013, 141999929126, 400000184756, 346000284216, 5999995630, 37999978142, 201000180852, 344000007720, 473999631946, 172000068884, 135999827502, 407000168772, 42000008946, 77999955034, 472000121680, 404999860788, 1999987788, 658999649212, 256000746494, 488000351584, 61999910494, 61999971810, 273999705598, 640999912160, 358999774469, 93000017886, 103999963084, 150999921438, 424999754232, 623999971981, 156000046304, 98001328344, 316999883412, 529000150267, 771999252648, 103000070208, 137000946765, 172999895824, 377999902070, 178999808344, 696999814623, 118000393324, 186000095088, 337999703310, 354999822560, 368999915905, 78999843302, 40999876365, 69999981463, 224000606060, 183999963946, 45000086652, 167000010896, 522999845095, 800999952225, 120999950170, 81000853918, 500999960848, 109000938940, 331999845579, 416000561566, 119999892652, 258000369750, 103999969208, 674999933355, 371000022931, 48000040033, 185999973174, 590999827098, 199999939374, 255999827208, 256000576828, 146000504080, 116000834484, 450000214250, 999939001, 35000049700, 614000387794, 288999858489, 578000087893, 751000022700, 61000305515, 137000192511, 640000065964, 99000079035, 214000466648, 191000181955, 154999848327, 403999603076, 251000196165, 608000076562, 879999755316, 58999928485, 273000280573, 2999945070, 44999996502, 439000274545, 17000630347, 136999940335, 771999534405 }

  11. {999999785,999999811,999999577,999999739,999999209,999999527,999999009,999999997,999999900,999999406,999999352,999999055,999999226,999999777,999999215,999999369,999999804,999999408,999999527,999999340,999999780,999999421,999999129,999999185,999999986,999999913,999999854,999999114,999999744,999999277,999999735,999999039,999999262,999999129,999999685,999999161,999999886,999999895,999999337,999999233,999999016,999999008,999999748,999999128,999999702,999999076,999999575,999999328,999999384,999999717,999999122,999999833,999999744,999999644,999999320,999999844,999999478,999999282,999999889,999999795,999999340,999999848,999999518,999999654,999999170,999999534,999999688,999999878,999999066,999999598,999999759,999999564,999999948,999999640,999999654,999999889,999999073,999999431,999999453,999999863,999999020,999999474,999999765,999999030,999999667,999999667,999999350,999999111,999999481,999999386,999999523,999999451,999999807,999999106,999999012,999999220,999999973,999999866,999999073,999999849}

    {884,298,373,283,471,650,119,201,816,877,194,894,159,105,335,136,123,526,788,333,811,114,40,102,598,293,691,121,762,558,35,581,55,666,55,224,236,19,142,227,376,414,512,340,393,882,523,514,967,71,934,595,505,108,832,512,286,407,569,623,52,215,119,255,355,316,561,991,122,53,119,902,320,288,894,891,956,260,303,229,644,385,497,235,456,918,201,756,671,241,272,511,743,577,228,587,65,959,740,159}

    {999999010,999999991,999999418,999999240,999999370,999999119,999999875,999999315,999999093,999999634,999999404,999999318,999999350,999999627,999999295,999999259,999999805,999999026,999999292,999999586,999999082,999999968,999999268,999999029,999999096,999999239,999999345,999999885,999999519,999999799,999999340,999999979,999999015,999999041,999999332,999999752,999999987,999999374,999999517,999999916,999999090,999999447,999999494,999999937,999999519,999999254,999999664,999999320,999999489,999999979,999999453,999999673,999999019,999999551,999999093,999999206,999999348,999999947,999999138,999999136,999999423,999999601,999999237,999999832,999999123,999999913,999999094,999999454,999999627,999999324,999999006,999999740,999999022,999999091,999999127,999999179,999999039,999999184,999999361,999999067,999999181,999999715,999999390,999999111,999999898,999999493,999999998,999999430,999999688,999999263,999999331,999999457,999999878,999999834,999999205,999999779,999999726,999999208,999999958,999999155}

    Returns: {998867573243425650, 996644097634230049, 997318031134294705, 996465411922459741, 997875439679903081, 998460185728109313, 991595538327847789, 995024187014927469, 998773502122640316, 998858789677527252, 994844123340590484, 998879806057691748, 993709276868424425, 990475598123892384, 997013439343835810, 992645695640170827, 991869530593533948, 998097295126051684, 998729784600588536, 996995925982254616, 998765816271472536, 991227469078963148, 974998439775619292, 990194307990981319, 998326841023424370, 996586183296994676, 998552021211383839, 991734550322409914, 998686927336081908, 998206963295843893, 971427660571601730, 998277850654063724, 981816485418899045, 998496670308642843, 981817209727481540, 995534634745740712, 995762585483052542, 947367700526381014, 992956609669331407, 995593869378916656, 997338536617914488, 997583000396682306, 998046117492315160, 997057893564758876, 997454692758413154, 998864545048308440, 998087193812762762, 998053125307849330, 998964747637336515, 985915195985920588, 998927912940522926, 998318834280727064, 998018565507182176, 990739942296455044, 998796490817924984, 998045925304811480, 996502325825514400, 997542229764165103, 998241557195175185, 998393794329230255, 980768018692680440, 995348286707037573, 991595401050786427, 996077919356920698, 997181395338754995, 996834892474723742, 998216251556432527, 998990250123175065, 991801986656079310, 981131012585174423, 991595407025449419, 998890657483483488, 996873970162551016, 996526511250326920, 998880213387326712, 998876733124670669, 998952087970556715, 996152465188924944, 996698486805629517, 995632118598381275, 998445408522540756, 997401788366383510, 997987083472980639, 995742829128519000, 997806583730297254, 998909835362914705, 995024229233830735, 998675791176432702, 998508856773634529, 995849275548169528, 996322386753995001, 998041962074662462, 998653790259781919, 998265840549540898, 995612260334115060, 998295423328962998, 984615084415392018, 998956321139835902, 998647681252742014, 993709696949813145 }

  12. {999999180,999999375,999999121,999999977,999999094,999999526,999999886,999999085,999999962,999999658,999999567,999999884,999999405,999999337,999999944,999999822,999999938,999999346,999999696,999999728,999999155,999999635,999999316,999999740,999999471,999999873,999999023,999999857,999999030,999999972,999999876,999999133,999999637,999999640,999999640,999999577,999999625,999999237,999999454,999999212,999999789,999999479,999999507,999999354,999999612,999999139,999999132,999999711,999999861,999999195,999999590,999999983,999999143,999999856,999999422,999999282,999999005,999999697,999999765,999999496,999999704,999999518,999999580,999999347,999999637,999999095,999999252,999999382,999999636,999999013,999999278,999999010,999999622,999999941,999999589,999999057,999999176,999999086,999999067,999999136,999999976,999999658,999999450,999999870,999999385,999999290,999999999,999999209,999999695,999999928,999999038,999999311,999999770,999999964,999999883,999999597,999999052,999999781,999999271,999999244}

    {290,999998677,999998480,999999642,682,464,206,999998654,999999174,999999328,999998940,743,999998846,999998904,999999858,780,999999058,506,391,999998795,471,954,177,999999075,995,799,715,999999343,990,999999648,434,999999089,999998637,318,645,7,288,615,182,815,341,999998616,999999443,600,337,999998886,999998626,937,341,999998946,999998624,517,196,916,999998923,999998746,999998521,322,919,148,999998746,999998825,999998655,50,999999481,999998791,623,341,880,967,184,999998076,838,999999429,410,999998497,391,307,89,870,999999873,999999179,999999236,999999288,379,146,999999883,60,39,625,847,999998809,209,773,975,247,999998941,350,919,677}

    {999999629,999999060,999999074,999999016,999999062,999999729,999999528,999999329,999999490,999999095,999999519,999999721,999999426,999999834,999999814,999999623,999999817,999999159,999999949,999999163,999999659,999999730,999999400,999999034,999999913,999999100,999999925,999999637,999999473,999999419,999999459,999999396,999999045,999999908,999999596,999999911,999999938,999999209,999999613,999999206,999999658,999999145,999999680,999999059,999999174,999999284,999999547,999999682,999999439,999999817,999999343,999999547,999999976,999999257,999999393,999999308,999999074,999999896,999999098,999999192,999999875,999999348,999999552,999999513,999999849,999999146,999999502,999999095,999999278,999999097,999999005,999999113,999999287,999999010,999999502,999999156,999999820,999999493,999999427,999999435,999999378,999999047,999999132,999999032,999999117,999999025,999999272,999999423,999999972,999999411,999999214,999999278,999999577,999999577,999999214,999999706,999999103,999999740,999999031,999999070}

    Returns: {996550537827888900, 73000170755, 368999819874, 138999740528, 998531882329295466, 997844084021680278, 995145045553451884, 121000128059, 160000116848, 317999709414, 411999926313, 998653710156156354, 316999958402, 347000022378, 30999991814, 998717393228272806, 342000345756, 998022222293040024, 997442101777509167, 198000104754, 997875674794342303, 998951147382698636, 994349005864814800, 136999846010, 998994359531704793, 998747408159063200, 998600348366507140, 361999913282, 998988402980309280, 152999871948, 997695187285781674, 13508, 581999614734, 996854896132108250, 998448848558285480, 857142465428583757, 996527343302106290, 998372431241253828, 994504567000210108, 998771425967496507, 997066896618840647, 422999871095, 44999990103, 998331748077274686, 997031429151655606, 49000046108, 23000434424, 998932157308523242, 997066749407702674, 34000181043, 309000269370, 998065294032889818, 994897086372466412, 998907410157313116, 269999943740, 392999808410, 417999649430, 996894003941025568, 998910723255925007, 993241937405811344, 190000843322, 571999690339, 221000532480, 979998886060309561, 53000029901, 276999773027, 998393619201014827, 997065928812875406, 998862550413899528, 998963985021574118, 994563507924628854, 796999435130, 998805592451344058, 109999722662, 997560068002643708, 352999838481, 997441455107564063, 996741254977660504, 988762559483671314, 998849146993591890, 82999938474, 363999637928, 171999846336, 410999558376, 997359982623233473, 993149008863703158, 26999925965, 983331991183779747, 974358656820519030, 998399339115242408, 998817616136529698, 199999997238, 995214660100575662, 998705879046587185, 998973456120092512, 995950722631697231, 64999949147, 997142378625771440, 998910163793959740, 998521211117394142 }

  13. {1000000000,999999999,999999998,999999997,999999996,999999995,999999994,999999993,999999992,999999991,999999990,999999989,999999988,999999987,999999986,999999985,999999984,999999983,999999982,999999981,999999980,999999979,999999978,999999977,999999976,999999975,999999974,999999973,999999972,999999971,999999970,999999969,999999968,999999967,999999966,999999965,999999964,999999963,999999962,999999961,999999960,999999959,999999958,999999957,999999956,999999955,999999954,999999953,999999952,999999951,999999950,999999949,999999948,999999947,999999946,999999945,999999944,999999943,999999942,999999941,999999940,999999939,999999938,999999937,999999936,999999935,999999934,999999933,999999932,999999931,999999930,999999929,999999928,999999927,999999926,999999925,999999924,999999923,999999922,999999921,999999920,999999919,999999918,999999917,999999916,999999915,999999914,999999913,999999912,999999911,999999910,999999909,999999908,999999907,999999906,999999905,999999904,999999903,999999902,999999901}

    {999999999,999999998,999999997,999999996,999999995,999999994,999999993,999999992,999999991,999999990,999999989,999999988,999999987,999999986,999999985,999999984,999999983,999999982,999999981,999999980,999999979,999999978,999999977,999999976,999999975,999999974,999999973,999999972,999999971,999999970,999999969,999999968,999999967,999999966,999999965,999999964,999999963,999999962,999999961,999999960,999999959,999999958,999999957,999999956,999999955,999999954,999999953,999999952,999999951,999999950,999999949,999999948,999999947,999999946,999999945,999999944,999999943,999999942,999999941,999999940,999999939,999999938,999999937,999999936,999999935,999999934,999999933,999999932,999999931,999999930,999999929,999999928,999999927,999999926,999999925,999999924,999999923,999999922,999999921,999999920,999999919,999999918,999999917,999999916,999999915,999999914,999999913,999999912,999999911,999999910,999999909,999999908,999999907,999999906,999999905,999999904,999999903,999999902,999999901,999999900}

    {1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000,1000000000}

    Returns: {1000000000, 2, 1000000000, 4, 1000000000, 6, 1000000000, 8, 1000000000, 10, 1000000000, 12, 1000000000, 14, 1000000000, 16, 1000000000, 18, 1000000000, 20, 1000000000, 22, 1000000000, 24, 1000000000, 26, 1000000000, 28, 1000000000, 30, 1000000000, 32, 1000000000, 34, 1000000000, 36, 1000000000, 38, 1000000000, 40, 1000000000, 42, 1000000000, 44, 1000000000, 46, 1000000000, 48, 1000000000, 50, 1000000000, 52, 1000000000, 54, 1000000000, 56, 1000000000, 58, 1000000000, 60, 1000000000, 62, 1000000000, 64, 1000000000, 66, 1000000000, 68, 1000000000, 70, 1000000000, 72, 1000000000, 74, 1000000000, 76, 1000000000, 78, 1000000000, 80, 1000000000, 82, 1000000000, 84, 1000000000, 86, 1000000000, 88, 1000000000, 90, 1000000000, 92, 1000000000, 94, 1000000000, 96, 1000000000, 98, 1000000000, 100 }

  14. {5 }

    {3 }

    {3 }

    Returns: {6 }

  15. {1000000000, 1000000000, 1000000000, 1000000000, 1000000000 }

    {1, 2, 3, 999999998, 999999999 }

    {342568368, 560496730, 586947396, 386937583, 609483745 }

    Returns: {342568367000000000, 60496729000000000, 253614062000000001, 773875166, 609483745 }

  16. {5, 5, 5, 5, 5 }

    {3, 3, 3, 3, 3 }

    {1, 2, 3, 4, 5 }

    Returns: {2, 1, 6, 2, 7 }

  17. {1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000 }

    {1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000 }

    {1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000 }

    Returns: {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, 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 }

  18. {2 }

    {2 }

    {1000000000 }

    Returns: {0 }

  19. {1 }

    {1 }

    {1000000000 }

    Returns: {0 }

  20. {515173 }

    {234 }

    {1000000000 }

    Returns: {512675487146398 }

  21. {1000000000 }

    {999999999 }

    {1000000000 }

    Returns: {1000000000 }

  22. {222222 }

    {222222 }

    {2222222 }

    Returns: {0 }

  23. {1000000000, 1000000000 }

    {999999998, 649384725 }

    {386937583, 128372993 }

    Returns: {773875166, 26300616100763300 }

  24. {1, 1, 1, 1 }

    {1, 1, 1, 1 }

    {1000000000, 1000000000, 1000000000, 1000000000 }

    Returns: {0, 0, 0, 0 }

  25. {1000000000, 1000000000, 1000000000 }

    {999999999, 999999999, 999999999 }

    {1000000000, 1000000000, 1000000000 }

    Returns: {1000000000, 1000000000, 1000000000 }

  26. {5 }

    {3 }

    {1 }

    Returns: {2 }

  27. {1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000 }

    {1, 2, 3, 999999998, 999999999, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000 }

    {342568368, 560496730, 586947396, 386937583, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000 }

    Returns: {342568367000000000, 60496729000000000, 253614062000000001, 773875166, 1000000000, 0, 0, 0, 0, 0 }

  28. {1000000000, 1000000000, 1000000000, 1000000000 }

    {999999999, 999999999, 999999999, 999999999 }

    {1000000000, 1000000000, 1000000000, 1000000000 }

    Returns: {1000000000, 1000000000, 1000000000, 1000000000 }

  29. {8888888 }

    {8888887 }

    {999999999 }

    Returns: {591111197 }

  30. {1000000, 1000000, 1000000 }

    {1000000, 1000000, 1000 }

    {1000000000, 1000000000, 1000000000 }

    Returns: {0, 0, 998998999000000 }

  31. {5, 5, 5 }

    {3, 3, 3 }

    {1000000000, 1000000000, 1000000000 }

    Returns: {1108216742, 1108216742, 1108216742 }


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: