CT52532

Leon's segments Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the honeycomb cliffs of Beeswick, Leon the clerk keeps careful count of the segments. Price the new merchandise line, every figure matters. Task: All values are positive. Print the length of the shortest contiguous subarray whose sum is at least s, or 0 if none. Input format: First line: n and s. Second line: n positive integers. Output format: Print the minimum length, or 0 if impossible. Constraints: 1 <= n <= 3899; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 2711 1015519938539 883113501 66614770 722655648 387786671 218554303 471247153 184407611 847950617 847888399 124117381 372614006 793763400 580784551 821913856 157119447 26054493 316358754 605892227 370056532 126226506 910146733 621677702 290916609 188509185 840734121 81886184 130351743 404467891 749548279 804229166 970168500 48546211 987317362 438972647 750028655 664215298 897653606 61915947 700918462 849507939 536465063 46657375 2530831 182730117 358458562 942307079 504502965 326750908 632315066 934639308 300646897 434321757 702004726 15797605 105766315 878375766 272121511 969948714 806688259 368031215 797467096 983355494 589252444 850086879 182605855 926042000 380632581 393450929 360442437 698643785 568172913 850554555 312840735 731237824 89817935 413621103 558841518 120828109 881659502 8…
Output: 2001

Example 2:

Input: 496 193561165578 15181352 51385192 41134367 1460450 306449228 858499808 541377095 586044836 446165237 170118187 898141887 191728207 848175017 84894177 86262457 267853089 375623967 954241381 42468554 450604539 5358785 686568883 29071099 660756905 809758536 459057453 580495587 28725426 366336994 665148294 330589732 52186775 336788792 442160415 834094787 117215738 483980591 877436844 2164518 580154048 79081137 543451919 589534880 615733410 563980908 522393519 686151603 88763841 149322032 529164164 986831277 287919347 883543822 9332702 428105388 556053734 515311923 321742056 712027531 668693934 708082841 943231851 888873126 761826447 882526339 443168213 137491727 409424933 681278520 146685736 148775092 432278733 111012833 18951269 223123308 680171397 36982391 59287938 867489463 211974960 60077…
Output: 373

Example 3:

Input: 2281 486355423649 801285092 351734171 595087072 422064050 561054334 366668800 702970671 296016840 927542187 299059310 422269232 464519104 73674981 533642305 24697624 891090888 398252713 693206014 850719161 901863863 813115505 42433234 168109576 368968536 39332966 224042870 938626386 569501647 77269402 668142171 447127062 793738838 676589609 567750145 86159857 618612364 202642928 237347094 803305548 326128199 672913479 751672582 893756650 466488247 441719867 826360416 633823397 14568163 830851851 35897865 928036892 992881624 67719567 622206677 714242152 793073268 997009862 661767646 452279375 882001075 416395038 511638718 645805229 927888854 487904680 509455557 303821769 768145195 424596400 944617914 235502496 63445336 559792830 212086936 965930316 214372313 550524684 957628961 616467360 38…
Output: 939

Constraints:

1 <= n <= 3899; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Loading...
Test Cases:No test cases
No test cases available.