CT46341

The Tightest Stretch at Vermilion

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the cinnabar mines of Vermilion as Mira unrolls the day's manifest of scrolls. The tally will decide the next shipment. 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 <= 1189; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 86 33967848984 906840883 931339313 920348263 880922668 180180110 938069007 596193800 580569960 164652025 29106906 20163043 211665307 271152277 660785513 702878678 225276738 629166506 530441922 234726110 459793199 828196620 702863095 746039523 454834903 348853152 207170468 188231813 391116377 263246952 177779667 308728002 139100242 723162585 138298926 721695197 180755815 301571670 886110678 759439655 844625084 559914507 135163339 159156260 33834652 404811763 906480183 341451615 658188789 894771848 200788764 353773936 882953559 514221200 739507614 23529808 195308710 136095069 427138512 432172054 387359552 734631870 453656266 629358922 57861713 786547680 960119833 278098229 410129507 933349874 236597664 374944718 231954595 250943565 5118000 504649715 298438513 883084987 708675645 44919977 770…
Output: 73

Example 2:

Input: 364 149639411589 429138449 907514366 982447311 607217318 477094084 886288900 394936807 364942634 972551541 303715971 678929236 132904645 190075012 681006654 566790729 245184278 874751596 12180939 583453754 484334334 191746718 984831233 788373770 909381024 346565277 93627918 124007049 808486329 502637258 321376935 447388317 537770620 24294427 235541407 430222928 783418126 383520994 549189737 834278799 153802217 206712633 61811702 977704153 530358847 340997558 44677323 134279406 589835896 477928444 689557436 649785072 368860017 276287837 415491764 207095523 899865342 524884563 813521460 446433596 765837490 841201070 136031681 809115651 464712799 293480963 159780307 673150428 63011477 813664436 522903854 215860794 910637296 792484925 308737415 621524474 373465436 605355436 838492644 132259375…
Output: 309

Example 3:

Input: 555 223328447478 510172086 356382398 484436844 749581018 241683291 90450666 180124908 748381869 553371545 347882921 331732537 711138561 532201495 116075818 755657489 491595758 512142910 594747668 529290745 959559616 476327484 142029773 918599727 641158868 705416168 689706654 285114853 294275406 714755659 518087804 880052646 849379958 779622840 902984800 117709179 298968858 181271562 939837941 578223939 990169784 594006029 93433208 285488588 27218618 863279391 819117625 354603829 209315356 214692665 543067366 966416230 764020916 10089506 744285553 264755933 627002754 909901128 349688725 711874559 98317178 748395878 178575598 911367222 650609102 661600619 640605559 677904238 733453591 651670337 226107422 796570078 901173577 919911565 744598521 368280620 959750274 675391808 564861666 66422760…
Output: 447

Constraints:

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

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