CT42797

The Tightest Stretch Beneath Buzzwell

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Shepherd inherited the ropewalk at the honey farms of Buzzwell along with its curious bookkeeping system for ribbons. Time to make sense of it. 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 <= 2438; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 797 377209231827 491114824 419661765 945426262 643317461 542109716 940679831 143391760 391499305 81252513 910314287 667414427 601638191 845090052 495063179 386837972 862361236 279837614 149159586 733661878 568138504 262685906 157239099 348973112 440801992 669130160 901727666 46957366 316666894 754560014 53703934 498071610 411337050 992469958 687793488 516040661 640826515 411095992 688356874 159423479 736954780 874788940 440473753 233740221 918062654 64092106 501427755 332269795 505741874 738157750 784712231 682771025 967378248 827086734 333845843 145610284 318366230 849663066 376107600 11521384 381949266 251949122 679721282 986857912 229557747 744598954 772082484 644930792 411443112 472133391 821649482 33457812 119302629 287804371 402034046 442028382 961677555 102173457 671921156 550267435…
Output: 757

Example 2:

Input: 587 174106963463 334690184 494197886 507543919 411798708 823038664 801950163 188773724 933766689 402439076 679035859 291705549 81695324 965406018 290346345 822943357 33509807 488846420 881152381 982266540 145431948 162557572 430621565 362703915 822977264 125766917 515350177 709589261 975804184 111346071 422054362 818892544 916922911 989477478 382511047 730449345 930607742 267000006 945061778 805507667 720216782 602300647 377797937 363700621 439268770 443937522 89774439 516933502 644817544 641880579 186201539 585046122 903776107 743745803 454174247 489972659 6506703 149074957 11027289 402150143 649691557 845726240 848940740 329189677 774708849 556016528 1154844 457400888 921977269 71674811 761481157 115050344 769050963 67700849 689735732 652517112 449710350 829488033 406603905 399585955 662…
Output: 354

Example 3:

Input: 1235 218789787849 9501368 754737087 956267796 464182181 176867558 881547035 920230752 321577521 357946107 103972005 361358120 712757418 918237849 65460725 458535240 287761982 789932262 887673253 481592158 754354463 330171280 178990068 123394897 638275160 83930831 400683562 923648380 89839581 69521640 134184701 570177187 813147668 453502570 985091634 858454925 779134047 727930720 573212260 260018404 874468130 651790997 209127280 796671966 102530367 431540381 620550535 123710956 228642682 931255893 290167529 117425762 947314818 970898854 566091553 609759812 548958062 401933434 562634035 746347280 404338285 992977060 501885440 151497430 14937175 430764361 516987084 451750107 448297162 28300673 302434662 908772750 742489771 138541555 479635886 553496333 615495402 592011309 230358617 779855505 …
Output: 421

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Tightest Stretch Beneath Buzzwell - MEDIUM Coding Problem | CodeTikki