CT46480

Ashen ribbons Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The archivist Gardener has been asked to price the new merchandise line. On the desk lies a long table of ribbons readings. 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 <= 2998; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 1789 576436532918 638887287 79310468 12625219 610927463 275032169 403828708 428682684 235295755 607704748 18461311 793217506 83374873 673491437 122296384 60860654 85497130 4370676 905944385 56916460 620677370 760642261 823908406 622702502 758042816 813111352 219964459 152155187 257482799 450358507 563499036 64473870 538102996 471933496 321044045 809668480 338446946 944743316 256969009 437983406 739901892 106659749 265168324 799913227 425352523 748554230 804569525 185370876 253222567 30215900 698942787 685840516 851001408 508594722 661119358 605542621 512047392 304592815 172827391 114545896 111943295 162569600 703161484 174075020 93047280 13446619 220949115 857121661 763383701 696598510 907406786 903874647 323446150 116325024 471130573 738344231 767987108 367516867 155452729 838552034 99775…
Output: 1137

Example 2:

Input: 698 22765548475 572408124 561611134 111901119 262423201 310885195 566860651 923155611 626812232 858817863 494253800 697417306 360716911 418769204 216181814 376375549 894163297 78889354 400437273 209106913 308414828 527855414 381633888 469157904 40373180 192578001 837173400 877988590 568625917 19394620 738054082 179431968 513891766 443393522 921447762 655739470 851144524 757197371 729362179 769305381 791240883 88551956 468047851 637427882 58192622 414159722 680386577 910639541 727030646 931002248 189489924 784233480 933772021 781673628 270622522 893801175 24320420 129953806 615968542 122636798 104630369 528851120 233908702 204309816 879998157 859387837 578133190 139438725 407995798 143163830 878207271 224307494 460022550 139114335 642750062 1659860 383964925 793774208 808215961 379795720 33…
Output: 40

Example 3:

Input: 115 55931637859 686573103 615724898 646459562 614702777 652660812 446669261 854198782 957560619 205254312 679261316 832593990 103524436 634957399 576139319 611071803 206889472 840436103 787426728 452726976 821931810 276077501 266797304 111958813 219476564 205976856 431027403 31505254 234732403 479213282 91921474 137843263 326791054 685246356 784265432 928999684 611268057 565044635 658299263 131239555 922047595 247522407 344721212 208050591 238971102 457216846 374213359 278464659 679800305 961113042 401281893 440298127 223996842 643650250 475134800 745248556 147024913 162906192 328571483 793343235 501212126 889373148 409366183 959706952 600501937 665790272 868521864 632820730 192373205 891604541 212330406 202315019 44392336 986615598 27755997 140882200 46679852 793884988 196839119 910774086…
Output: 115

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Ashen ribbons Tightest Stretch - MEDIUM Coding Problem | CodeTikki