Statistics

Problem Statement for "SunShroom"

Problem Statement

A Sun-shroom is a mushroom in the Plants vs. Zombies game. When you plant a Sun-shroom, it starts its life as a small mushroom. After two minutes have passed, the Sun-shroom instantly grows to a full-sized mushroom.

While the Sun-shroom is small, it produces 15 sun every 24 seconds. (A "sun" is a unit of currency in the game.) Once it's fully grown, it produces 25 sun every 24 seconds instead.

The first time a Sun-shroom produces sun is 24 seconds after it was planted. At two minutes into its life the shroom first grows and only then produces sun, so the produced amount is 25 sun.


You are given a long[] plantingTime. Each element of plantingTime is a time in seconds (counting from the beginning of the game) when you planted one mushroom.

You are also given a long queryTime (in the same units).

Calculate and return the total amount of sun produced by your shrooms during the first queryTime seconds of the game.

Definition

Class:
SunShroom
Method:
produceSun
Parameters:
long[], long
Returns:
long
Method signature:
long produceSun(long[] plantingTime, long queryTime)
(be sure your method is public)

Notes

  • In the actual game you have to purchase the Sun-shrooms before you plant them. In this problem we do not care about these costs.

Constraints

  • plantingTime will have between 1 and 50 elements, inclusive.
  • Each element of plantingTime will be between 0 and 10^12, inclusive.
  • queryTime will be between 1 and 10^12, inclusive.

Examples

  1. {10}

    33

    Returns: 0

    Ten seconds into the game you planted your only shroom. Then you waited for 23 more seconds, but the shroom hasn't produced any sun yet.

  2. {10}

    34

    Returns: 15

    This time you waited one more second and you were rewarded by the first batch of sun produced by the shroom.

  3. {47}

    200

    Returns: 110

    This shroom had enough time to mature and produce its first two bigger batches of sun.

  4. {47, 47, 47, 47, 47, 47}

    200

    Returns: 660

    The same test case as above, but you have planted six shrooms at the same time.

  5. {10, 100, 20, 200, 30, 300, 40, 400}

    123456

    Returns: 1027230

  6. {100000, 300000}

    200000

    Returns: 104110

  7. {472714946146, 500594072362, 376113681617, 563746360070, 431156979568, 45593488708, 462976354951, 28598584390, 115781006843, 287765499666, 531683642348, 600109398664, 991345931129, 624125653083, 250945058219, 572251743796, 393049434127, 35399330168, 410431136258, 758992585513, 658648063549, 611353864467, 839988671581}

    262834747001

    Returns: 872766944200

  8. {137590475322, 108808392514, 637213539850, 559993206404, 895673031138, 104165131105, 960564318197, 252892449071, 768485673032, 368704154404, 516334757416, 123455308678, 458586863889, 389144030819, 960676185459, 967597369403, 892377964756, 890084654251, 391965543077, 620763152655, 528453247696, 619816207952, 437140329685, 570071915662, 243952487305, 127158282853, 926112661968, 417501256536, 276962678892, 665558197681, 165605533908, 14791379313, 188897504382, 689544082805, 836678235575, 81959898389, 559487135727, 686390132194, 522039808145, 883828402876, 401302901790, 837168496645, 665862444952, 988980702115, 668487142918, 999327694137, 703121304235}

    911885951626

    Returns: 18207611123060

  9. {268765828340, 378864926640}

    763932154393

    Returns: 916909951795

  10. {516154899298, 218703878719, 107923406865, 799450866706, 626142251204, 581298290048, 117649293121, 486477481641, 717261479324, 455792133464, 404015395253, 287851807464}

    150502977886

    Returns: 78576307995

  11. {561520352970, 540459665508, 859857385110, 892377695667, 581945283051, 620423449313, 11026628440, 80294564125, 915580178482, 371701262902, 951917331171, 962273187986}

    260369714764

    Returns: 447310663395

  12. {412579863353, 22003753087, 331092967505, 966599106069, 337360471374, 671041902011, 807009241165, 165506080830, 638017083691, 299627345370, 943256368080, 631315711514, 618821908064, 375772074527, 58224817534, 128648171208, 457042407239, 997951725827, 619775859518, 836849860620, 659231331100, 69319277848, 562515435019, 992640241711, 719240655084, 501595732057, 20717484080, 890924749712, 573652710479, 859277749551, 316922307514, 776460271949, 551861216575, 829418866418, 387599837701, 364197126897, 507523046697, 644342135100, 734861112465, 701268459908, 753959692315, 758900445918, 29715657018, 618316616502, 902756106711, 316451471744}

    846284162128

    Returns: 14787835325040

  13. {530609936368, 74662437551, 866391206142, 966835942117, 779626170672, 659664011268, 590460587123, 870780278032, 637209777343, 452310294578, 750631384170, 987396311570, 804038793592, 101500890993, 563081725738, 338482607364, 589839694332}

    398728625200

    Returns: 709937437030

  14. {936703077442, 818717083008, 396967191407, 382467889930, 951691023728, 697467716754, 295524254479}

    228725629014

    Returns: 0

  15. {511999646966, 729504684889, 901174221091, 330527868576, 484367955593, 950551218743, 63026471499, 636322067896, 2060295352, 463974681249, 506231356622, 483270680235, 895990561896, 282866066763, 112931705667, 134445683572, 188692505734, 371184335257, 470288305650}

    261801498489

    Returns: 841511281650

  16. {565089997760, 344727395064, 23857645055, 669664796276, 960668521586, 942227007732, 646798924445, 655827693651, 685862684608, 510746739172, 612535271037, 748095257302, 415331491977, 46447885339, 670795011086, 201558993385, 84283927431, 453054429021, 245071996309, 195256613453, 661127066501, 6003905151, 153005827810, 80501630260, 427607767388, 420910035684, 813893414711, 693444476521, 804761767594, 558871814508, 113389209751, 867952919035, 452776700011}

    978998982200

    Returns: 17265434994105

  17. {936750676046, 191629790225, 734025279356, 521832366111, 654721582264, 102343283425, 577224291439, 358653982579, 822196664968, 218671368443, 435150562882, 85245478165, 367166531569, 715756032521, 275328204502, 869668434134, 102969619291, 433919399570, 657479275061, 567898781543, 230399520144, 281353848781, 943661297949, 551072539565, 127154873077, 618102969733, 313800827395, 196364337519, 766601297502, 443418056613, 522313646690, 644275495946, 441835642112, 260313902438, 410402941219, 866729392350}

    369825524575

    Returns: 2152251849765

  18. {649214693565, 262447796805, 952815208205, 86686301857, 563249376012}

    790996180745

    Returns: 1669152660965

  19. {99115964687, 644786045594, 946584098799, 134639976957, 459397327294, 602561899388, 243269252604, 843303585264, 704761613996, 113018435694, 219197032939}

    617663782974

    Returns: 2554631865545

  20. {364913590074, 915218418517, 843185096789, 728922086122, 472085694402, 599174650742, 827092929243, 750630601452, 390415559610}

    574655864870

    Returns: 517242448280

  21. {701907176848, 478627384419, 453875789928, 539996669508, 210550786948, 360642648251, 657340758229, 472181702259, 111244991879, 847994450584, 135647102196, 928126512874, 478178745134, 365325676198, 867477634018, 205104547205, 897278418789, 449549422587, 813762316114, 521915635176, 569911063696, 253069250522, 688047782198, 592818788846, 358602174280, 158570914670, 178994449933, 321152322785, 51851383338, 922329548287, 665310781426, 48527549584, 681361907404, 738101656214}

    279199941791

    Returns: 1207540103540

  22. {5857, 14607666, 359, 286978148, 81979605, 246507517, 8369982, 71486, 237379, 8, 46354791, 13265930331, 304824124, 31, 147942, 1443, 30215, 1497768131, 265257, 131, 93454, 31665376822, 13638}

    36127049

    Returns: 539645950

  23. {1771516, 1, 3, 11, 8604368869, 36885789034, 32347735, 4831, 234731, 5789029456, 25, 445449585854, 15, 973634708, 117239125, 112, 22696922, 277763, 2, 370, 32, 249009784, 123887855, 174949255841, 896, 34339595178, 84877, 17, 155169726072, 2, 160, 871642702213, 72458708332, 1322, 20227, 803, 499544272096, 265041149, 3899995326, 3669764, 55393659707, 58818919, 6, 990}

    40355407

    Returns: 1029298085

  24. {1, 5536424, 596395912658, 131657817, 198221, 3811559, 806935087318, 390959, 902939807, 881, 165, 2979, 23801956402, 22546479, 2878852627, 7394, 1775510286, 51860222747, 81, 233175, 193, 40191032205, 29267708, 393708, 453765892234, 108265206722, 443027738, 228751816950, 155889, 371196, 6, 765436437649, 28, 117, 755318, 92582126, 45, 64391734798, 854970, 10380821, 52, 764351578, 18329, 1695355, 73317, 24, 773370370, 6489961925, 429136, 201003968}

    914309690810

    Returns: 44334540474575

  25. {35488, 3, 6908, 230035052243, 5702772651, 2691, 17, 64707523, 850265244049, 3281090, 24, 903586189019, 850331850, 1519, 3533, 26508, 5, 3, 1, 240070, 593677405, 40, 368933862, 35776, 63898124, 19429877048, 66763206343, 24004258865, 1512, 214566, 8135, 5474968250, 109708, 17067506749, 17455, 381, 1501688}

    1245881

    Returns: 26518860

  26. {13559534381, 10729417, 2276, 333348928763, 284148, 1437536, 60, 156928, 729134, 202448689022, 3, 4304, 181000599, 258713, 7770, 1, 5052493978}

    391057571063

    Returns: 6347265052270

  27. {880867023630, 17808, 48559081757, 501469, 2772, 53515948470, 289292, 564066, 990416610112, 126727939841, 899, 24299896, 15291095173, 55050855, 2619936, 31387114, 301, 32999, 68863, 3760703, 24537023025}

    74405

    Returns: 335910

  28. {11, 3492, 4895554, 227542, 8977, 129400, 19967, 16487641961, 3673, 183925, 9279038424, 1369931, 257446, 100, 48274515, 22220, 50, 16389871629, 92, 9933, 8187, 26925107, 3608673, 80086716, 53, 95910, 206095789488, 100131757952, 3738730353, 7574, 3946, 293013271085, 30262, 7297, 4112, 65027, 14154420655, 1691143, 786210388962, 16240, 272477180162, 60541925, 470, 4302722}

    20372891601

    Returns: 764854442990

  29. {839175685601, 566, 9057, 91304773109, 14656705, 20751, 39721, 440, 10, 25856114, 12773029289, 53883, 818905435, 108, 31214185297, 15519056413, 884, 362, 2, 14, 3032383463, 10, 65448290838, 15, 6769036934, 5239903523, 6820, 1, 68072139178, 1621, 15642516612, 1900, 35720242, 34571973958, 333675348007, 16090, 4358, 17695940179, 3182591, 1671268135, 78, 8248521, 1, 132799713435, 2552, 113857, 594751008, 2288236845, 156205298}

    11679788

    Returns: 304134335

  30. {2605612633, 314278, 2981428173, 5, 228856, 852, 329, 243398966, 115144952800, 118, 308, 22, 2, 20015399, 31}

    172

    Returns: 470

  31. {20928, 14, 1882, 38780089685, 60729, 8298727166, 56144, 180437, 6, 5, 12, 982449, 13, 11285627315, 4293, 23474852419, 120268, 1085247230, 3804181, 36, 778857565109, 110364}

    190421525004

    Returns: 4079085560935

  32. {251031, 64369, 3724, 23430659, 6, 5, 19, 193843, 2021248347, 860424216247, 117101500370, 14513341, 1204, 2076378135, 325408, 495620524, 209061135832}

    48562

    Returns: 247525

  33. {5, 6, 3210618904, 9116, 4459985001, 166013, 83197940, 186, 12488979419, 490104327410, 1611233, 1, 7984161245, 3122108, 374329, 695933211, 18879211103, 36, 45824990562, 1951, 22, 14811942, 8172, 4556, 3, 60965465809, 1, 63008705792, 12279434, 95, 7263, 125955, 1147853830, 1341, 7007, 370157280439, 8, 3, 86327405, 506627294, 1351, 10421322467, 348, 2691640199, 116796315, 2, 195244066950, 700271, 211282}

    3363

    Returns: 49660

  34. {197189000370, 2972, 36773214, 9417984, 289346930, 96, 2981937}

    8557895

    Returns: 23633880

  35. {23306, 5614, 3081227, 18788297, 1811088, 529360876, 1069475794, 149283978878, 129471480, 1825749, 179975969, 13869681543, 73340107, 6747111, 818059450838, 9697, 3767350642, 271515475013, 3, 45457, 3036908, 3, 6798349263}

    58164352708

    Returns: 1184202784475

  36. {754176720404, 24, 121402093113, 239173518901, 111841, 169388, 2694552983, 715278004809, 820817, 7, 14894010, 37457692237, 102656, 1620219054, 7336, 130019955, 12, 2561663278, 16324174470, 73315270117, 392, 45, 865714004444}

    6878

    Returns: 35075

  37. {1000000000000, 10000000000, 10000000000, 10000000000, 10000000000, 10000000000, 10000000000, 10000000000 }

    900000000000

    Returns: 6489583332995

  38. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }

    1000000000000

    Returns: 10416666666100

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

    1000000000000

    Returns: 29166666665080

  40. {10 }

    33

    Returns: 0

  41. {1000 }

    100

    Returns: 0

  42. {100 }

    3

    Returns: 0

  43. {10000000000, 12000000000 }

    12345611111

    Returns: 2803356370

  44. {10 }

    34

    Returns: 15

  45. {10000 }

    3

    Returns: 0

  46. {10, 100, 20, 200, 30, 300, 40, 400 }

    1000000000000

    Returns: 8333333331805

  47. {1 }

    121

    Returns: 85

  48. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }

    1000000000000

    Returns: 12499999999320

  49. {60 }

    20

    Returns: 0


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: