Statistics

Problem Statement for "Moneymanager"

Problem Statement

One day Hero realized that he has zero experience with practical projects. Thus, he decided to spend one whole year on projects, gaining some experience and making some money along the way. Hero already chose which projects he is going to do. All that remains is to choose the order in which he'll do them. Each project can be described by two positive integers a[i] and b[i]. More precisely, when Hero works on project i, the following two things happen, in order:
  1. First, his work on the project increases his experience by a[i].
  2. Then, when the project is done, he earns money for the project. The amount earned is (b[i] * E), where E is his total amount of experience at the moment of finishing the project.
The number of projects Hero has planned is even. In addition to the projects, Hero has one extra plan: after finishing exactly one half of the projects, he wants to attend a training camp. The training camp will increase his experience by X. He will not earn any money at the training camp. At the beginning, Hero has no experience and no money. You are given the int[]s a and b (both with the same number of elements; that number is even) and the int X. Find and return the maximum total amount of money Hero can earn during the year.

Definition

Class:
Moneymanager
Method:
getbest
Parameters:
int[], int[], int
Returns:
int
Method signature:
int getbest(int[] a, int[] b, int X)
(be sure your method is public)

Constraints

  • Number of elements in a will be between 2 and 50, inclusive.
  • Number of elements in a will be even.
  • a and b will contain the same number of elements.
  • Each element in a will be between 1 and 100,000, inclusive.
  • Each element in b will be between 1 and 10, inclusive.
  • X will be between 0 and 100,000, inclusive.

Examples

  1. {1,1}

    {2,1}

    0

    Returns: 5

    An optimal solution: Hero works on project #1 (zero-based index). He first gains 1 experience and then he makes 1*1 = 1 money. Hero goes to the training camp and gains X=0 experience. Hero works on project #0. He first gains 1 experience and then he makes 2*2 = 4 money. The total amount of money earned during this solution is 1 + 4 = 5.

  2. {1,1}

    {1,5}

    10

    Returns: 61

    An optimal solution: Hero works on project #0. He first gains 1 experience and then he makes 1*1 = 1 money. Hero goes to the training camp and gains 10 experience. Hero works on project #1. He first gains 1 experience and then he makes 5*12 = 60 money. The total amount of money earned during this solution is 1 + 60 = 61.

  3. {4,4,6,6}

    {2,2,3,3}

    100

    Returns: 726

    One optimal solution: project #0, project #1, training camp, project #3, project #2.

  4. {44,68,47,81,34,91,24,5,85,59,7,9,100,18,6,34,1,79,91,99,60,2,24,85,96,11,40,13,30,89,74,78,72,13,14,33,96,69,14,18,14,63,95,71,87,57}

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

    40

    Returns: 327332

  5. {43,97,33,97,77,57,67,84,45,30,13,3,3,73,72,49,36,91,11,24,68,76,47,24,37,12,27,98,70,73,29,56}

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

    29

    Returns: 159618

  6. {71,86,90,95,14,98,36,26,62,90,79,81,42,62,74,23,76,25,86,57,93,24,51,3,80,17,6,55,71,3,95,2,34,63,35,55,8,93,79,26}

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

    17

    Returns: 212683

  7. {83,45,83,36,38,98,91,51,64,41}

    {4,6,7,1,4,6,1,3,1,4}

    19

    Returns: 17409

  8. {29,4,43,50,14,88,14,58,17,63,60,4,45,62,44,30,64,40}

    {2,2,5,1,6,3,5,5,7,6,7,3,6,2,2,6,5,1}

    50

    Returns: 42962

  9. {75,71,98,92}

    {3,3,4,3}

    95

    Returns: 3510

  10. {13,20,26,55,36,65,73,3,88,44,24,80,89,77,12,68,2,85,95,88,50,35,13,99,17,28,37,12,19,70,90,48,35,67,5,97,44,70,77,97,67,36,42,17}

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

    56

    Returns: 296438

  11. {22,9,20,53,27,28,99,43,82,25,75,99,96,25,88,43,22,44,63,20,78,48,24,75,65,61,43,54}

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

    44

    Returns: 126688

  12. {89,53,37,73,89,15,79,83,84,42,36,62,6,45,88,3,79,32,74,6,62,25,34,83,37,46,50,3,62,22,76,100,94,36,45,44,38,70,77,34,99,46}

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

    97

    Returns: 267198

  13. {33,8,61,22,6,64,1,11,57,45,32,40,81,32,91,29,97,27,32,43,44,33,74,83,29,71,10,94,34,92,91,79,16,74,78,80,62,51,14,94,9,59}

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

    5

    Returns: 269411

  14. {15,7,43,81,92,29,62,49,36,74,99,64,98,92,72,9,75,24,1,92,13,45,57,58}

    {3,1,1,3,2,5,3,7,3,6,2,6,5,6,5,7,3,6,5,7,6,2,2,7}

    11

    Returns: 98820

  15. {99,87,48,67,99,95,74,18,21,100,7,12,32,12,7,39,88,67,75,49,92,58,84,73,55,43,80,85,12,34,47,54,26,48,82,64,63,71,27,52}

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

    79

    Returns: 282515

  16. {76,31,53,4,93,36,59,34,64,56,71,92}

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

    26

    Returns: 18846

  17. {22,21,12,12,91,56,24,13,4,33,56,98,80,53,80,80,62,51,57,75,27,30,99,62,25,51}

    {1,4,7,7,1,4,4,6,6,6,5,1,6,1,3,1,5,7,1,6,5,5,5,7,1,3}

    9

    Returns: 107846

  18. {86,58,8,88,54,1,63,40,84,16,13,10,41,28,81,90,29,89,97,96,63,86,46,80,58,48,3,100,28,31,51,78,65,100}

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

    93

    Returns: 182667

  19. {73,42,29,24,21,68,67,84,96,86,93,57,9,34,17,35,60,64,39,10,21,12,47,12,34,56,7,91,44,84,76,58,63,96,15,1,45,9,54,37,63,53}

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

    45

    Returns: 241058

  20. {30,13,28,59,26,62,48,75,6,69,94,51}

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

    62

    Returns: 22096

  21. {36,37,75,84,80,37}

    {6,6,4,1,5,5}

    20

    Returns: 7607

  22. {97,92,96,45,65,23,71,28,36,98,42,91}

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

    64

    Returns: 32445

  23. {92,41,60,8,18,80,91,15,80,27,48,78,90,86,59,77,53,21,1,46,9,38,62,49,3,61,12,70,56,39,35,28,78,64,29,75,65,73,64,74,68,15,52,68}

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

    22

    Returns: 270763

  24. {17,41,15,75,62,5,21,60,59,85,63,53,47,79,11,95,94,7,61,35,73,20,77,92,98,100,30,57,85,45,27,23,3,19,84,70,60,59,93,38}

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

    1

    Returns: 237625

  25. {10,96}

    {4,5}

    37

    Returns: 1052

  26. {22,48,40,8,89,37,66,63,74,98,98,81,1,80,85,33,85,75,13,64,20,92,63,44,68,66,100,62,30,41,94,51,81,94,22,21,95,26,95,87}

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

    16

    Returns: 240227

  27. {30,35,79,79,40,24,48,7,26,59,56,42,57,56,37,22,85,80,85,75,99,86,14,33,39,18,42,76,41,60,85,22,6,41,43,33,45,28,40,23,56,17,24,1,84,45}

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

    15

    Returns: 294285

  28. {46,91,3,51,38,30,16,58,44,11,9,52,32,54,44,99,72,44,86,53,42,32,93,79,89,3,63,29,42,34,65,41,21,68,53,31,8,22,65,82}

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

    38

    Returns: 222549

  29. {25,84,54,33,8,2,24,65,25,32,88,95,16,31,51,20,2,34,76,92}

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

    83

    Returns: 54010

  30. {50,1,52,18,56,18,26,22,43,79,84,6,63,22,63,67,95,79,66,57}

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

    98

    Returns: 71110

  31. {71,80,15,10,81,36}

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

    54

    Returns: 6045

  32. {52,1,35,66}

    {5,3,1,3}

    54

    Returns: 1997

  33. {100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000}

    {10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10}

    100000

    Returns: 1300000000

  34. {99653,99292,99806,99451,99132,99330,99108,99164,99005,99887,99371,99884,99290,99911,99826,99600,99189,99061,99690,99504,99997,99206,99715,99915,99893,99976,99584,99948,99135,99779,99398,99323,99389,99843,99593,99765,99988,99307,99369,99742,99036,99593,99282,99857,99829,99531,99600,99609,99677,99334}

    {10,9,8,10,9,9,10,10,10,9,8,8,10,10,9,9,8,9,8,10,8,10,8,9,9,10,9,10,8,9,9,8,8,8,10,9,8,8,9,10,9,8,8,8,9,8,10,8,9,8}

    100000

    Returns: 1208671562

  35. {21674,18843,28598,19763,29935,10336,1935,11407,18986,3045,26815,30047,99856,67033,11088,82189,81894,33958,65656,33749,81990,21886,32643,59043,99042,40001,36697,49527,55421,98099,10802,88327,30294,25067}

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

    85191

    Returns: 217223076

  36. {38144,94468,51647,38181,66934,58291,52524,3005,21585,6959,37907,94409,88000,23918,36306,94034,62901,59479,69191,45199,69260,26202,60824,3285,4696,97111,15440,27513,79930,62089,2674,75378,40372,45013,28314,67933,78496,40469,25514,21118,38514,5663,98295,52871,57587,66957}

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

    32740

    Returns: 469833334

  37. {56143,46697,44433,53897,74677,7857,9867,41384,64645,37430,32313,33203,11503,75773,17972,36249,34536,91791,45711,64824,80768,7676,82647,96224,14737,10812,83927,4898,39570,15773,9429,89356}

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

    10929

    Returns: 210450836

  38. {39071,83186,49790,76895,83514,58698,51236,70026,51862,70890,4879,94981,58542,54862,98274,25823,53776,825,15286,45257,81193,24,84951,28203,30080,35217,11006,96255,18071,13503,76695,83602,50234,53863,74735,19255,80108,14293,3679,70626}

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

    44617

    Returns: 354681484

  39. {29983,68745,25083,51336,60638,15998,26591,19951,97164,57941}

    {7,8,10,1,8,10,1,1,8,9}

    22619

    Returns: 22724766

  40. {46229,70804,31843,33150,66914,14588,61114,91958,30217,80763,23760,84404,4845,51062,12244,26430,45064,17740}

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

    81650

    Returns: 60618668

  41. {975,76771,79598,292}

    {8,1,10,1}

    49895

    Returns: 3879642

  42. {99813,23720,71926,14155,21836,32065,30473,76003,84488,99344,83524,11380,84889,12977,3512,32468,12802,89785,8495,17388,68050,11935,29413,42799,51317,56328,39837,87612,77019,2670,4590,84448,63635,85167,25205,96497,41644,87470,25977,72997,2167,99636,85342,63317}

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

    1056

    Returns: 388412531

  43. {78922,90209,43920,69053,63427,13428,20199,38643,48582,24725,9475,59899,34796,38625,66788,54243,42922,16744,30763,36720,80378,27448,69724,58675,44465,10961,98143,88554}

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

    49044

    Returns: 141267004

  44. {65689,23253,36037,35573,85189,66715,95279,10183,984,98942,13736,5062,39406,52945,69488,82103,72979,84932,94974,25706,82462,99425,40234,28483,63737,58146,57450,80703,20662,93422,33176,35200,32894,75236,15445,26344,50038,86170,13277,52834,51999,28246}

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

    35897

    Returns: 418356485

  45. {98133,11108,82261,10222,97406,39764,13601,49611,73457,21245,86132,7840,44681,37132,2791,53829,68197,39527,17932,52243,21544,81733,88874,36383,75429,20171,41110,14694,97034,52892,77291,34279,56316,34674,28278,73980,20162,26551,41514,44394,69409,75759}

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

    51005

    Returns: 312388713

  46. {18315,69707,17543,76081,81892,25629,26062,29649,64436,89574,58099,32964,20298,3892,7172,2809,54275,81624,47701,48592,4813,63545,94657,87758}

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

    31311

    Returns: 120242485

  47. {74599,12387,30548,30967,93699,24695,26874,93418,77021,99200,66607,97712,19632,7012,55107,5639,11188,2567,72575,41349,31992,34858,26884,19673,76855,7043,17980,11285,83712,83534,3647,70854,32226,83948,49882,43364,50863,63371,99627,13752}

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

    10679

    Returns: 284787923

  48. {39976,16231,83453,99504,28393,54236,96259,39834,51864,48756,89371,92}

    {1,5,5,1,7,4,10,1,1,1,7,4}

    70826

    Returns: 26921484

  49. {98722,81921,82012,72612,8991,1956,19524,70013,56704,33733,57456,498,51380,98053,7580,16280,39562,26451,99557,70275,75327,2330,72699,62262,12725,2751}

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

    61809

    Returns: 120204302

  50. {14,23,18,13,5,16,15,27,16,15,5,17,16,23,8,19,4,8,26,19,10,26,23,23,22,21,7,27,1,9,2,17,14,7}

    {2,3,2,3,3,4,4,1,2,3,3,3,1,4,2,1,4,2,1,4,3,1,1,4,4,4,2,3,3,2,1,3,2,3}

    91

    Returns: 36950

  51. {4,8,7,11,4,1,4,25,15,9,17,9,30,28,16,24,21,19,21,9,30,12,24,15,16,1,10,3,10,9,24,18,12,3,14,23,16,19,14,8,24,13,25,21,7,17}

    {3,4,2,4,1,4,4,2,4,1,4,1,4,1,1,3,4,3,1,2,4,1,4,2,2,1,1,4,3,2,1,2,4,3,3,4,3,4,1,1,4,1,3,4,1,1}

    40

    Returns: 58130

  52. {3,7,23,27,7,7,17,24,25,10,13,23,13,3,22,19,6,21,21,24,18,16,17,4,17,22,27,18,20,23,9,16}

    {2,3,2,3,4,1,3,3,1,2,1,2,2,1,2,4,4,1,1,2,3,1,1,2,2,4,3,2,3,2,2,1}

    29

    Returns: 26620

  53. {21,26,10,15,24,8,6,26,2,10,9,21,22,12,14,3,16,25,26,27,13,4,1,23,20,27,6,5,1,3,5,2,14,3,15,5,18,23,19,16}

    {1,1,2,4,1,1,3,4,3,4,3,2,2,2,3,3,3,2,4,3,2,3,3,1,4,1,3,4,2,4,4,2,4,1,4,3,2,3,2,2}

    17

    Returns: 44250

  54. {13,15,3,6,8,8,11,11,4,1}

    {3,4,2,1,4,4,3,1,4,3}

    19

    Returns: 2050

  55. {9,4,23,20,24,28,4,28,27,13,20,14,25,2,4,20,4,10}

    {4,3,3,2,4,2,1,2,1,3,4,4,2,3,3,1,2,2}

    50

    Returns: 11129

  56. {25,11,8,22}

    {4,1,4,3}

    95

    Returns: 1366

  57. {13,30,16,5,26,5,13,3,18,14,14,20,9,27,22,28,12,15,15,18,20,15,3,19,27,8,7,22,29,30,20,18,25,27,5,7,4,10,17,27,17,6,12,17}

    {4,2,2,1,3,2,1,4,2,4,2,1,1,3,1,3,4,2,1,3,4,1,2,3,2,4,3,4,3,2,3,2,1,4,2,2,2,2,1,3,2,3,3,3}

    56

    Returns: 56707

  58. {12,9,10,23,7,8,29,23,12,25,25,9,6,5,28,23,2,24,13,10,28,8,24,25,25,21,3,14}

    {2,1,4,3,3,4,4,1,1,2,3,1,2,2,3,4,4,3,2,4,4,3,1,3,2,4,3,3}

    44

    Returns: 26193

  59. {19,3,7,23,19,25,29,23,4,2,16,12,6,5,18,3,29,22,14,6,12,25,4,3,17,26,30,23,12,2,16,10,4,16,15,14,8,20,17,14,29,26}

    {4,1,1,3,1,4,1,4,4,3,3,4,2,2,1,1,2,4,2,4,4,1,2,1,4,1,3,2,1,2,2,4,3,3,1,1,4,1,2,4,3,4}

    97

    Returns: 54334

  60. {3,18,21,12,16,24,21,1,7,15,2,20,21,2,11,19,7,27,12,13,4,3,14,13,19,21,10,4,24,2,21,19,16,14,8,10,12,21,24,14,29,19}

    {3,2,4,4,2,4,3,1,4,1,2,3,4,2,4,4,4,2,1,3,3,2,1,3,1,1,2,1,3,3,1,4,2,1,2,1,1,2,3,1,1,3}

    5

    Returns: 42432

  61. {15,17,13,21,12,19,22,19,26,4,29,4,28,2,2,9,15,4,21,22,3,25,17,18}

    {2,2,3,2,2,2,4,4,3,4,4,1,3,3,3,4,3,3,3,4,2,3,3,2}

    11

    Returns: 17641

  62. {9,27,28,17,29,25,4,18,21,30,17,2,2,12,27,19,8,17,5,9,22,18,14,13,5,13,30,25,12,24,27,24,26,18,22,14,23,21,27,22}

    {3,2,4,4,4,3,3,4,2,4,3,4,4,4,2,1,2,3,2,1,3,4,1,2,4,1,1,2,1,2,2,1,2,4,4,3,2,2,3,4}

    79

    Returns: 59739

  63. {6,21,13,4,13,16,29,4,14,26,11,2}

    {3,1,3,1,1,4,4,3,3,1,1,4}

    26

    Returns: 4129

  64. {22,1,12,2,11,6,24,23,4,3,26,28,30,3,10,20,12,21,27,25,7,20,19,2,25,11}

    {1,2,4,2,2,4,4,1,1,3,3,4,1,1,2,3,2,4,2,1,3,3,2,4,2,3}

    9

    Returns: 19180

  65. {99653,99292,99806,99451,99132,99330,99108,99164,99005,99887,99371,99884,99290,99911,99826,99600,99189,99061,99690,99504,99997,99206,99715,99915,99893,99976,99584,99948,99135,99779,99398,99323,99389,99843,99593,99765,99988,99307,99369,99742,99036,99593,99282,99857,99829,99531,99600,99609,99677,99334}

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

    100000

    Returns: 1000470520

  66. {1, 1 }

    {2, 1 }

    0

    Returns: 5

  67. {93659, 55005, 65993, 17295, 39597, 45143, 54626, 99879, 6229, 78523, 30130, 21378, 43249, 56118, 36917, 70033, 95731, 44176, 39556, 71386, 44931, 86055, 18816, 58215, 32184, 58678, 46435, 887, 68509, 50466, 82725, 28595, 16516, 61971, 42141, 57716, 73023, 72689, 85699, 79465, 2997, 17587, 62721, 58909, 78509, 43035, 24197, 17596, 16424, 54790 }

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

    42666

    Returns: 490282255

  68. {10, 1 }

    {10, 2 }

    10

    Returns: 212

  69. {7, 1, 2, 2, 13, 19, 2, 1, 16, 4, 15, 4, 18, 5, 17, 3, 13, 9, 19, 20, 8, 13, 10, 14, 8, 20, 10, 5, 2, 17, 14, 8, 17, 15, 1, 1, 5, 2, 2, 1, 6, 8, 16, 15, 12, 12, 18, 4, 1, 8 }

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

    111

    Returns: 116497

  70. {336, 973, 96, 455, 290, 906, 124, 814, 239, 221 }

    {7, 9, 10, 4, 1, 7, 7, 1, 5, 5 }

    680

    Returns: 222609

  71. {42, 18468, 6335, 26501, 19170, 15725, 11479, 29359, 26963, 24465, 5706, 28146, 23282, 16828, 9962, 492, 2996, 11943, 4828, 5437, 32392, 14605, 3903, 154, 293, 12383, 17422, 18717, 19719, 19896, 5448, 21727, 14772, 11539, 1870, 19913, 25668, 26300, 17036, 9895, 28704, 23812, 31323, 30334, 17674, 4665, 15142, 7712, 28254, 6869 }

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

    10000

    Returns: 166904750

  72. {84686, 25591, 35241, 54887, 20311, 82953, 26224, 71467, 99649, 47447, 12226, 60354, 85831, 89550, 13128, 54953, 61682, 15232, 77192, 74844, 46825, 64650, 14680, 85270, 22456, 31439, 27163, 87440, 80983, 53424, 49501, 50039, 76592, 84085, 64049, 20283, 8778, 76462, 56590, 22743, 13667, 41035, 76636, 82842, 91014, 63134, 84917, 858, 46764, 3034 }

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

    12345

    Returns: 532343684

  73. {43, 18, 46, 29, 43, 16, 8, 44, 29, 49, 46, 8, 28, 48, 34, 26, 38, 24, 50, 44, 40, 4, 36, 1, 2, 30, 40, 30, 33, 8, 14, 5, 19, 40, 41, 22, 17, 35, 30, 21, 30, 29, 19, 49, 9, 26, 50, 45, 14, 3 }

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

    34

    Returns: 289923

  74. {385, 1522, 612, 995, 670, 896, 1369, 538, 1438, 1515, 987, 964, 771, 72, 1855, 1443, 1725, 697, 1438, 1331, 1208, 1340, 1785, 974, 228, 520, 1165, 1865, 872, 42, 569, 1937, 1831, 1187, 1716, 938, 249, 1796, 1112, 1098, 1148, 91, 500, 1259, 845, 869, 1034, 1707, 592, 1005 }

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

    23000

    Returns: 14319918

  75. {45, 39, 66, 13, 89, 75, 16, 44, 55, 29 }

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

    54

    Returns: 19125

  76. {1, 20 }

    {1, 10 }

    100000

    Returns: 1000211

  77. {97289, 38767, 89312, 80345, 32992, 78026, 24898, 49831, 20446, 69415, 35773, 76228, 33457, 89298, 45508, 22480, 48270, 27869, 98955, 55981, 47053, 20028, 59278, 77154, 19848, 64231, 9096, 42329, 60320, 40475, 59581, 77792, 95000, 12921, 81040, 88140, 10168, 15238, 85037, 13905, 33804, 36489, 99809, 89227, 93218, 75984, 67229, 31865, 80592, 76267 }

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

    100000

    Returns: 562832738

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

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

    1

    Returns: 250751

  79. {29388, 19683, 11967, 55570, 25634, 41158, 34365, 55983, 14365, 11971, 24676, 59417, 15757, 82615, 73139, 18094, 27907, 52736, 85017, 68849, 96268, 27141, 20989, 51715, 83079, 71194, 31220, 53800, 57961, 31201, 39319, 69884, 8082, 43141, 27072, 72419, 81843, 46242, 3898, 30851, 2519, 71250, 3071, 97891, 69988, 71812, 29008, 92813, 71564, 53667 }

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

    23333

    Returns: 453942072

  80. {34, 44, 63, 30, 1, 9 }

    {3, 7, 7, 10, 2, 2 }

    44

    Returns: 5041

  81. {100000, 100000, 1, 1 }

    {9, 10, 9, 10 }

    0

    Returns: 6700029

  82. {100, 100, 1, 1 }

    {3, 4, 3, 4 }

    100

    Returns: 3211

  83. {506, 753, 717, 439, 502, 872 }

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

    124

    Returns: 101659

  84. {24843, 61394, 67799, 58315, 50070, 15429, 42655, 18660, 30096, 58330, 41945, 33320, 69002, 62409, 79329, 27517, 60669, 93064, 41620, 38049, 37542, 32237, 37247, 73900, 46990, 61458, 47571, 56662, 35563, 47616, 74010, 38399, 41130, 52490, 57002, 26214, 59081, 74742, 38877, 37183, 46438, 65759, 43261, 40553, 52632, 64729, 44802, 50424, 56064, 52568 }

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

    69271

    Returns: 493771502

  85. {31323, 30334, 17674, 4665, 15142, 7712, 28254, 6869, 25548, 27645, 32663, 32758, 20038, 12860, 8724, 9742, 27530, 779, 12317, 3036 }

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

    23812

    Returns: 30555157

  86. {42, 335, 170, 479, 963, 706, 282, 962, 996, 828, 392, 903, 293, 422, 719, 448, 772, 870, 668, 36, 704, 323, 674, 142, 254, 548, 663, 38, 724, 530, 317, 191, 289, 41, 265, 447, 891, 371, 7, 394, 630, 85, 757, 967, 932, 945, 627, 538, 119, 930 }

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

    833

    Returns: 5384485

  87. {1, 4, 4, 3 }

    {2, 2, 4, 4 }

    2

    Returns: 120

  88. {92331, 18071, 73616, 91197, 21808, 3222, 97756, 17217, 32721, 57956, 30645, 20759, 42877, 77102, 54073, 6974, 52865, 49162, 97423, 60429, 14124, 67868, 12072, 9044, 8569, 70834, 24219, 29780, 48380, 48482, 46792, 1378, 48101, 80949, 11473, 30201, 71341, 80412, 97337, 83976, 69959, 4091, 51906, 46399, 50784, 85891, 18060, 34149, 90460, 56134 }

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

    83946

    Returns: 464272613

  89. {2, 1 }

    {3, 2 }

    1000

    Returns: 3011


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: