Statistics

Problem Statement for "Election"

Problem Statement

N candidates, indexed from 0 to N-1, participate in an election. After the voting is over, candidates are sorted by decreasing number of votes, and by increasing index in case of ties.

With the voting underway you have your favorites for different positions. You wonder how many additional voters would have to come to make your selection possible.

The int[] votes represents the results so far, where the k-th element is the number of votes received by candidate k. The int[] wishList corresponds to the positions where you would like to see the candidates after the voting is over. If element k of wishList is -1, it means that you don't care where candidate k ends up. Otherwise, the number represents your desired 0-based position for candidate k. Return the minimal number of additional votes needed to make it possible for the final ranking to match your wishes.

Definition

Class:
Election
Method:
votesNeeded
Parameters:
int[], int[]
Returns:
int
Method signature:
int votesNeeded(int[] votes, int[] wishList)
(be sure your method is public)

Constraints

  • votes will contain between 1 and 50 elements, inclusive.
  • wishList will contain the same number of elements as votes.
  • Each element of votes will be between 0 and 10,000,000, inclusive.
  • Each element of wishList will be between -1 and N - 1, inclusive, where N is the number of elements in votes.
  • Elements of wishList, other than -1, will be distinct.

Examples

  1. {10,8,6,4}

    {-1,0,-1,2}

    Returns: 6

    If 3 more people vote for candidate 1, and 3 more people vote for candidate 3, the vote distribution would be {10,11,6,7}, and the final candidate ranking would be {1,0,3,2}, which matches your wishes.

  2. {10,20,30,0}

    {-1,-1,-1,0}

    Returns: 31

    Candidate 3 will need 31 votes to take the lead.

  3. {10, 100, 40, 15, 15}

    {4, 0, 1, 3, 2}

    Returns: 1

    It's almost as wished, but the tie breaker rule would make candidate 3 come before candadiate 4. One more vote is enough to fix that.

  4. {5052863,4419975,3556783,9490441,6166389,836297, 4623556,4905465,117307,8071245,932463,9194925}

    {-1,-1,-1,-1,2,0,-1,-1,8,9,4,11}

    Returns: 53562445

  5. {0}

    {0}

    Returns: 0

  6. {0}

    {-1}

    Returns: 0

  7. {10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000}

    {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}

    Returns: 0

  8. {10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000}

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

    Returns: 1

  9. {10000000,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}

    {49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0}

    Returns: 490001225

  10. {10000000,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}

    {-1,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0}

    Returns: 490001225

  11. {554851,7496813,130161,8998565,3023450,6215723,8655348}

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

    Returns: 24911547

  12. {7651154,3601326,1271320,2703001,764832,6664721,9372528,9957670,9371077,1578439,55567,7664590,2034623,8315557,5011808,6145181,737763,8605825,8754764,2819487,9145747,2574926,2802356,2382761,7292172,6956210,1810623,4871946,2998083,3842659}

    {19,11,-1,28,18,26,10,16,9,-1,1,27,2,22,14,17,-1,29,21,13,12,8,7,20,-1,3,15,23,5,4}

    Returns: 134142206

  13. {6310184,2551549,9800424,6158768,4016789,9193573,5141128,9729831,9024989,9217444,886725,2630106,3383503}

    {11,4,7,8,9,-1,6,1,2,12,3,10,0}

    Returns: 46445614

  14. {2579434,6752349,7596880,5182707,5612384,9083463,6503200,5444,5941634,9583517,6267040,2065111,3854748,2993622,1037029,2485402,7131285,4955022,887351,2742920,8467660,8801350,2982171,3302935,3435486,8910226,6921164,7471137,7124206,1484776,8833813}

    {-1,-1,-1,19,-1,-1,2,28,27,5,29,25,24,22,-1,7,26,11,8,21,6,15,10,23,13,9,3,0,-1,12,18}

    Returns: 88539323

  15. {2930900,6196462,9655659,324181,2356188,2223331,1587171,2319044,171373,1548056,5753026,9089282,2354962,2036277,9884398,209328,6033797,3825310,5970839,4120448,227108,5729588,5356683,4483953,8156135,8312096,7261399,3005940,8163674,2477032,2951872,3685991,9488180,7750619,1729337,6327177,2072677,98020,8221854,9809874}

    {33,8,0,-1,36,10,35,22,11,17,3,-1,30,18,14,25,37,19,23,2,-1,20,32,26,34,-1,38,12,13,31,39,-1,21,-1,15,16,5,28,-1,7}

    Returns: 168811294

  16. {474828,4112347,4127192,30025,2803451,4326208,9263359,7201254,5055149,2713961,167864,8709176,9637266,738268,469813,7741549,1355793,5977406,5932861,9645717,2560,6555928,2856395,5068026,8971387,6918328,6924278,4447008,2617876,4199457,5322646,2010846,6759789,3540223,8827856,4216878,7311389}

    {12,-1,11,-1,28,27,-1,-1,-1,5,-1,18,17,-1,26,-1,-1,22,-1,32,21,7,-1,24,-1,-1,8,-1,-1,-1,-1,-1,-1,16,-1,-1,-1}

    Returns: 143566529

  17. {8904908,9227683,9529221,6170094,8205722,6152243,2804056,4172224,7356457,7370337,7793424,5113238,1305556,685978,602765,3786734,6686707,5044520,7135325,4150744,9919263,1000141,433741,7829648,6953173,9749117,7267046,654400,3055818,6658110,3368842,192408,7212646,443469,3445036,7689887,5492749,571433,1076288,7401264,8034957,4755929,1414119,4696119,6323214,2578053}

    {-1,34,-1,37,-1,23,22,16,-1,17,-1,26,-1,-1,33,8,39,31,24,20,-1,21,41,9,35,7,-1,2,4,-1,-1,44,28,-1,30,-1,15,-1,43,45,-1,13,12,1,25,18}

    Returns: 178309821

  18. {6428560,491698,7409803}

    {-1,-1,0}

    Returns: 0

  19. {9304235,9149373,7849739}

    {-1,0,2}

    Returns: 154863

  20. {9417059,7241795,3550415,1364185}

    {-1,-1,-1,-1}

    Returns: 0

  21. {4328220,3267752,6913799,8655383,8578761,6446393,2441733,1988886,3253903,8397342,4728911,17469,1280957,1156396,3852508,9688716,9961466,2712477,9618682,3232094,146541,2428482,9677560,3516096,6323976}

    {1,2,14,21,16,4,9,-1,23,3,18,10,8,22,15,-1,5,20,0,17,6,7,13,11,12}

    Returns: 98603824

  22. {8536633,8398838,6773125,3043702,2871289,7584991,270397,3322119,9184096,797264,9637156,6063009,4955437,851633,6269716,97160,5258272,155125,8437476,5676232,8246625,615657,6874636,4956156,5022029,9690782,8238777,355937,4153592,6151697,3219093,8424795,8859980,1158531,7162714,1811908,2807419,6941017,8860377}

    {12,26,10,-1,-1,-1,-1,-1,-1,-1,38,-1,-1,-1,34,28,-1,-1,-1,20,35,33,-1,-1,-1,-1,23,-1,11,-1,-1,-1,29,31,27,32,-1,-1,-1}

    Returns: 174167728

  23. {9734408,7730492,7446306,3876857,4113493}

    {4,-1,-1,2,-1}

    Returns: 15770488

  24. {2088598,1089984,397130,7235753,8634204,6341735,4476060,2533893,1706256,3971363,5784410,4008604,9242588,3789913,9062235,7566697,4022574,9288750,600229,9799390,2745327,6717195,3571778,534944,8022542,8031674,9242195,1879837,8355035,1710517,2956749,8210921,6064651,4665586}

    {4,-1,17,20,18,-1,5,-1,-1,30,-1,-1,33,28,-1,-1,-1,-1,29,-1,-1,-1,1,23,-1,-1,-1,16,-1,-1,6,-1,8,25}

    Returns: 140548055

  25. {407059,3472735,499938,7508894,4006082,2661556,6641015,9286940,7641706,3693063,6109640,9613144,7568958,1685981,3557803,5148217,2351007,7528564,2454541,6473365,5078737,8637086,7890759,1724731,1453858,286192,6486460,8983640,4770663,7535841,8982198,2412437,1557092,6131845,5627979,5721224,5621040,4966319,3339706}

    {-1,-1,-1,-1,-1,-1,27,24,-1,0,-1,2,-1,-1,11,-1,-1,-1,17,5,-1,-1,-1,-1,-1,-1,-1,-1,13,-1,-1,37,28,-1,-1,4,-1,-1,-1}

    Returns: 84071469

  26. {2889205,6035406,1409814,3819423}

    {2,0,-1,3}

    Returns: 3339828

  27. {9761052}

    {0}

    Returns: 0

  28. {4671191,7307371,618691,9995808,4764487,1786039,7307201,3173356,7737442,7017730,4996924,3186650,2719164,7004127}

    {-1,-1,-1,-1,-1,-1,-1,13,-1,-1,-1,-1,-1,-1}

    Returns: 4396177

  29. {8083961,9030525,5336769,4988044,2514323,4021296,2045957,6214365,5853852,7528198,9503929,3882313,9244034,9774379,3855285,5463544,3953125,200591,1167649,6211542,6204523,4928791,2477693,2475001,1493576,9512906,1238422,6631751,8175948,7874354,4995255,2717244,4118998,3116700}

    {-1,-1,1,-1,16,-1,-1,-1,-1,-1,13,21,29,-1,3,-1,17,-1,-1,15,25,11,9,-1,-1,-1,0,-1,-1,2,-1,23,5,-1}

    Returns: 112402768

  30. {6073384,3242941,4519816,5713556,1204553,6497273}

    {-1,-1,-1,-1,-1,-1}

    Returns: 0

  31. {3530023,4674995,3461429,3603296,4455173,1880706,7186254,4360295,4687496,3607840,4238591,114413,7521403,568742,9091475,3458210,5653027,5028887,3430293,5267969,8492061,6838206,4056511,6268347,692762,3778203,9686535,5982596,4694470,5541787,3800135,8373335,2822435,1219498,9572407,5996052,34643,5148004,2794611,4994008,2141336,6172787,4567623,8847792,7339297}

    {-1,-1,32,30,-1,-1,41,36,-1,14,-1,20,12,-1,40,-1,-1,6,7,-1,28,21,13,42,31,18,25,9,33,-1,22,-1,39,0,17,37,-1,-1,5,-1,16,26,10,-1,34}

    Returns: 186604243

  32. {4790452,8468804,4245010,6420024,18663,6509554,5287738,2750787,6320871,7447251,5307468,1181061,2556037,1119682,6144873,4330396,3608667,1246740,8464303,8790123,2470446,9642096,7207926,5120486,4232157,9174714,758891,1157613,6943437,3317411,6660888,2716789,9335576,7514606,1109251,9445695,8381832,420363,955788,8037479,7428975,2715334,7295313,5150708,4300875,4858482,9645282,9176458,1322925}

    {-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,32,-1}

    Returns: 78497594

  33. {9831292,2691775,5855913,9804832,3491238,2662311,2195630,9131931,7379012,6030514,764112,4411225,7387577,2867011,5663364,1070984,7628344,488057,7584758,7980821,5664705,7617865,5913184,7531859,3445691,5643672,3927551,7009782,1731704,2311922,191834,6805598,1741262,2994587,6412510,6778854,7039383,5447540,1976762}

    {-1,13,21,25,29,7,9,-1,20,17,5,4,34,14,10,8,6,2,30,24,22,11,33,32,37,3,27,23,26,35,18,19,36,28,0,16,31,12,38}

    Returns: 139948230

  34. {7958633,1612398,4591605,3260211,4086751,1540126,5098128,1749109,4280219,1812729,2352725,6053230,5769893,6172505,5903828,1205959,2071433,8610078,5589299,4719945,9101120,6040537,6657093,7402280,5194743,337443,5371150,6598334,6620861,6761570,315942,5716448,4161360,9064347}

    {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}

    Returns: 4383340

  35. {5789008,5628182,1231982,6293092,5455901}

    {4,0,-1,2,3}

    Returns: 6059128

  36. {995631,6341074,7898382,524390,1384572,5409173,1378522,8196851,2045656,1921140,7613774,5125800,7930944,6844823,2603349,3483507,651441,3931694,8885579,4056546,3706914,8104744,6800690,5308585,2324437,5000915,7827260}

    {17,1,25,3,19,9,8,20,26,5,-1,-1,12,22,15,6,21,2,24,13,23,18,4,-1,-1,0,10}

    Returns: 105787272

  37. {1938563,7556397,3719556,3678534,8246383,4447024,8431480,7433558,6949297,1976685,9160992,184670,553853,4470221,9183249,4130004,9344578,334984,2969622,245315,7403535,7249811,5217812,1338030,7559013,7841589,6256689,7787321,3709815,280895,423539,1988050,1292739,1309043}

    {-1,21,-1,-1,-1,1,-1,-1,15,-1,-1,-1,-1,-1,3,-1,-1,-1,-1,-1,25,-1,-1,12,-1,-1,-1,-1,-1,-1,-1,-1,-1,18}

    Returns: 55249185

  38. {2900847,7116760,6447862,8831888,2573340,2182769,7856867,8070925,8733915,8646677,6277243,7274327}

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

    Returns: 25954136

  39. {2181849,1620079,7895743,1813788,8016969,1504585,3466084,829633,8957748,2817133,3593579,4532791,9694974,2824039,3568816,5689326,7617668,7167423,4986247,6348090,1082480,2634163,5151617,802974,3255867,4477468,1387862,7106896,1839469,188532,5470623,8507866,2724380,4349963,4278940,7192738,1309332,6656823,5873404,6246629,5313580,2538311,8151543,6664316,1038760}

    {5,4,33,1,37,38,16,23,41,32,12,36,25,22,11,34,18,40,7,20,9,10,15,44,43,24,30,31,28,42,39,3,0,6,26,8,29,13,19,2,14,35,17,21,27}

    Returns: 203337161

  40. {9767144,698951,2829411,8192342,9280507,5915454,3654924,5623184,6891224,7233097,9612492,1979879,9034401,1723650,234615,6412341,8623444,3164422,3104915,2764095}

    {-1,-1,1,-1,18,-1,15,-1,16,-1,-1,8,-1,-1,-1,-1,-1,-1,-1,-1}

    Returns: 70974413

  41. {1967304,6785461,5542223,457607,5488379,7471412,2324030,930313,6105428,9910959,7405002,3663164,8947341,4260778,5997245,7330314,5619898,3150683,2393275,5196749,3477983,3858128,1566671,2733024,9644403,272735,4831809,1540060,5627760,8116862,8491261,30016,6283787,4112136,1990577,9170822,3405185,7517726,4445353,3607401,3373182,6643620,6923286}

    {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}

    Returns: 0

  42. {8061288,261838,2578130,6875150,273101,5251013,544205,6712242,6521568,8500871,1680015,1664600,8151277,3863268,6303095,9020213,1544359,9877817,4394666,8472097,7609932,6636184,6376271,5691411,566446,7425389,3577641,1694693,5689116,1944010,1413924,3328043,5112894,3484267,791130,6487538,127747,6968151,4926742,2244887,4072600,8153397,8888839,9233396,5200223,7042374}

    {45,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,21,-1,-1,-1,42,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}

    Returns: 176375519

  43. {1312281,1298725,2335970,3747553,5863546,5077247,8088272,3793692,2012654,92372,9600236,6889982,5260237,152429,5669869,1214794,6970159,9130252,5862990,4886072,6821245,1216367,7064331,2919160,5180979,1411849,9915596,4230609,4403966,5312402,1093924,9842249}

    {-1,-1,-1,-1,-1,30,-1,15,-1,22,-1,-1,17,24,-1,-1,-1,-1,18,-1,14,-1,-1,19,5,-1,-1,-1,-1,-1,3,28}

    Returns: 148196017

  44. {9384314,5402321,4937118,3455938,2490170}

    {-1,-1,-1,-1,-1}

    Returns: 0

  45. {487611,9501778,7426277,9637891}

    {0,-1,-1,3}

    Returns: 11498007

  46. {8248443,2983393,5741632,5077807,2451629,9215601,8377236,3607931,2332751,9922132,6489050,4163284,2486135,9757853,9959550,5932315,2706343,411632,4082630,1764350}

    {-1,19,-1,6,0,17,11,1,14,-1,5,-1,-1,8,-1,-1,-1,3,7,-1}

    Returns: 71949855

  47. {6487655,4228700,7869041,9290902,3068970,442812,6585137,8047912,3343004,6133643,3656284,1019741,1712682,7432305,3241275,9551229,3466886,1583051,9692598,3655040,8577867,5034762,8478240,7051110,8281377,4392931,7963515,6821147,6090521,7509442,2447375,4931225,6584920}

    {-1,-1,-1,-1,31,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,15,-1,8,-1,6,14,-1,-1,-1,-1,-1,-1,9,-1}

    Returns: 20315095

  48. {5172053,5611686,7791000,307130,6861844,4879874,2011686,2412199,3841985,2977932,1959701,3189739}

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

    Returns: 37587408

  49. {5771921,7199685,3216836,9218661,2261346,8236677,5442720,4140431,3009440,4819618,5389969,6685896,8700703,4273586,1679831,9316504,9569143,5819510,206848}

    {1,-1,-1,10,-1,-1,0,-1,-1,18,8,-1,-1,13,16,7,-1,3,-1}

    Returns: 36543575

  50. {3064901,8484801,8178909,1575990,3635732,2744941,6990544,5556645,3750109,7319497,3026456,1459760,7072926,1353221,960061,5768483,3167172,1588219,4051471,9560889,2834756,6103638,1986256,5914154,4598381,982281,4332488,9363878,8330542,5047847,8445163,9738269,5778138,6765262,75679,5141298,5126823,2074688,4589822,8728844,5458520,7542597,7946250,5672953,4240962,1080833,1116047,3163699,2503190}

    {26,-1,-1,18,-1,-1,4,14,-1,-1,27,13,12,19,-1,21,-1,17,39,-1,16,-1,-1,-1,11,-1,-1,36,34,-1,35,29,43,1,31,-1,47,32,-1,-1,-1,23,44,-1,37,10,-1,-1,-1}

    Returns: 203612014

  51. {4071331,3127441,213197,5128461,4935448,9145021,1270700,5474352,4353681,7958000,8690087,4489535,3672203,4210716,6041629,7614338,7650517,3173585,6772807,2941421,9444893,7087311,9991500,7210367,617824,609807,8298097,6147949,947311,8802603,6151396,4510035,2421028,2088512,5374284,5535062,2590296,3864053,5150577,3029419,7768272,5769573,5255854,1935816,4187499,3940251,1377513,4420722,4515420,8208935}

    {-1,-1,-1,27,-1,-1,12,-1,13,-1,34,31,4,-1,2,47,5,48,38,9,-1,-1,-1,-1,-1,32,6,25,8,26,11,-1,-1,14,1,28,40,-1,21,39,42,-1,-1,-1,-1,44,10,17,3,29}

    Returns: 171033340

  52. {7683577,9744133,3822650,3105685,2314298,1729138,2059781,450125}

    {-1,-1,-1,1,-1,6,-1,-1}

    Returns: 4577893

  53. {4019885,2528121,6063083,7848071,929856,9618907,878634,8623121,5395490,2984857,4377769,477488,7910979,4972551,8440673,9919592,7008495,7371743,9067896,6517388,2383345,5645354,5837887,550552,8863466,406293,6661837,8936149,1911867,5176492,8346388,6660286,7174122,9532732,3134752,4295955,9700098,4909000,1906760,6184082,9770341,6826474,5508365}

    {5,-1,22,7,10,-1,0,-1,-1,39,-1,25,-1,-1,28,11,34,1,6,-1,20,17,14,37,16,-1,32,-1,-1,21,23,-1,15,18,29,19,-1,36,-1,42,35,-1,-1}

    Returns: 151534828

  54. {5088291,8123067,8769246,8257134,5284056,6137868,8944451,7256976,6295150,7453676,2008031,7384633,7478445,728997,2864948,1131883,754443,8100702,6582005,493489,4797874,3345585,7528913,295727,5600212,5430770,5598702,3787265,5112473,750888,1788945,9713634,8756505,1551511,4454151,8790865,5790388,4493376,1011233,1617317,4200795}

    {25,40,-1,-1,31,-1,16,-1,1,5,0,17,19,23,-1,29,20,-1,-1,10,24,21,33,-1,18,35,-1,9,38,32,22,4,-1,27,11,6,-1,37,8,30,39}

    Returns: 147300772

  55. {7992867,2477152,9371627,5377663,1529870,1628152}

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

    Returns: 11880432

  56. {3016830,3134192,9619151,4140416}

    {2,1,0,3}

    Returns: 2129811

  57. {1455961,5383506,4238391,7689451,7486469,9062705,878739,2543294,9190459}

    {-1,-1,-1,-1,7,5,-1,-1,-1}

    Returns: 22426691

  58. {5153561,3864752}

    {-1,-1}

    Returns: 0

  59. {7688600,8000274,2608122,394304,6225768,4964568,5161181,7823277,4060839,9495756,6046267,2699185,5914393,5324667,3729091,3210602,3796955,3469922,9796381,8584556,4435055,5169715,9400733,4277759,2847707,4616712,316101}

    {2,0,7,-1,-1,3,11,23,13,4,16,19,12,1,9,14,6,18,24,25,5,15,-1,10,-1,-1,17}

    Returns: 113830061

  60. {5032867,6342324,8939078,641080}

    {-1,-1,-1,3}

    Returns: 0

  61. {10000000,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}

    {47,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}

    Returns: 470000047

  62. {5052863, 4419975, 3556783, 9490441, 6166389, 836297, 4623556, 4905465, 117307, 8071245, 932463, 9194925 }

    {-1, -1, -1, -1, 2, 0, -1, -1, 8, 9, 4, 11 }

    Returns: 53562445

  63. {2, 1, 0 }

    {2, -1, -1 }

    Returns: 5

  64. {5052863, 4419975, 3556783, 9490441, 6166389, 836297, 4623556, 4905465, 117307, 8071245, 932463, 9194925, 112, 321, 1, 1 }

    {-1, -1, -1, -1, 2, 0, -1, -1, 8, 9, 4, 11, 3, 7, 1, 10 }

    Returns: 72249849

  65. {10, 100, 15, 15, 16 }

    {4, 0, 3, 2, 1 }

    Returns: 2

  66. {123456, 575468, 123457, 58754, 56658, 708678, 3454567, 7689, 56879, 432577 }

    {4, -1, 5, 8, -1, -1, -1, 1, -1, -1 }

    Returns: 1321107

  67. {10, 100, 40, 15, 15 }

    {4, 0, 1, 3, 2 }

    Returns: 1

  68. {100, 100, 100, 100 }

    {-1, -1, -1, 1 }

    Returns: 2

  69. {100, 19, 101, 13 }

    {-1, 2, -1, 0 }

    Returns: 173

  70. {5052863, 4419975, 3556783, 9490441, 6166389, 836297, 4623556, 4905465, 117307, 8071245, 932463, 9194925, 111111 }

    {-1, -1, -1, -1, 2, 0, -1, -1, 8, 9, 4, 11, 3 }

    Returns: 57008114


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: