CT41379

The Tightest Stretch Beneath Willowford

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the river town of Willowford as Farhan unrolls the day's manifest of windows. 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 <= 1337; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 636 260590 720 700 622 855 992 245 521 642 337 293 845 247 196 867 994 490 318 228 172 955 440 653 129 289 761 438 956 703 769 281 833 816 639 958 25 597 178 490 156 336 282 33 255 897 16 874 43 912 807 742 915 257 109 531 577 890 549 707 370 204 234 932 667 338 662 940 244 586 356 169 63 263 537 562 134 825 788 911 902 125 256 263 114 877 405 861 474 994 8 636 205 142 117 365 22 216 654 166 743 777 399 662 77 705 818 303 218 304 586 299 844 69 954 571 326 432 758 526 692 990 405 41 760 604 898 907 681 561 932 234 508 455 234 20 563 462 81 272 752 334 548 620 346 181 801 858 199 215 684 365 288 445 142 863 104 655 119 273 336 286 220 851 953 10 888 596 673 584 727 927 390 714 789 926 462 65 124 587 462 145 969 134 681 121 616 269 997 616 472 265 935 108 94 273 897 247 636 799 937 852 943 5…
Output: 511

Example 2:

Input: 55 23439 454 189 534 101 789 104 235 832 999 28 928 684 170 263 453 879 228 665 977 487 799 573 409 312 140 960 728 209 750 586 787 199 188 454 189 853 798 176 713 356 338 789 292 101 802 258 220 44 877 696 649 77 191 746 207
Output: 47

Example 3:

Input: 93 22345 557 254 799 680 311 7 538 885 811 484 867 226 412 924 205 463 70 734 939 380 139 309 386 768 35 136 921 18 600 772 443 32 611 742 684 3 647 886 708 634 251 859 962 233 566 895 200 985 803 204 321 260 457 406 75 885 349 533 526 9 770 254 169 817 169 66 435 917 750 69 33 790 289 810 690 222 658 917 488 4 615 212 96 418 746 723 424 584 872 267 856 933 108
Output: 42

Constraints:

1 <= n <= 1337; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

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