CT43816

The Ruby Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Hugo runs the chandlery at the cotton rows of Whitewick. Today the books show a list of ribbons, and the numbers must be worked out before sundown. 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 <= 1851; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 523 114174652 181977 645322 724050 810344 428899 50046 659197 116026 933244 218880 819878 294892 11996 838843 636687 331537 885986 160590 228592 859069 53672 647901 953424 882488 498608 73765 915672 946721 788805 724469 451513 394914 947251 408850 588012 971881 60448 602155 794964 570520 82730 235942 52465 152669 521419 856015 139824 251773 874840 575305 39973 235401 343471 854264 918112 792323 399538 755295 397173 217485 349699 629624 469998 748478 530456 78050 26077 108958 341905 322549 653241 961780 610630 139756 576238 987181 798989 534553 14883 788484 715193 277892 887516 667142 82716 989190 131241 179789 769616 560723 805910 788567 749610 284064 466172 3115 99073 595115 746613 932320 802320 933176 91828 269226 377534 79786 124542 654529 613619 833016 578867 460620 680005 233774 30554…
Output: 226

Example 2:

Input: 851 410237337 320405 462203 292912 758123 725736 849889 372330 589715 901517 870276 931256 833439 985592 354502 704332 920734 807762 628709 858620 31802 773542 911829 932840 829825 656598 629719 456087 349432 618790 705434 666199 837615 704448 699383 73514 758393 128516 623096 349325 184427 353028 853240 476473 354842 552724 197458 16030 520338 191392 204761 514084 608974 717753 573591 654793 969095 27108 835182 793362 470487 798647 817123 115895 518315 739235 284582 718499 921522 243628 587112 664973 724655 330836 759216 18585 915188 593217 819840 699310 813078 20970 641591 920869 571353 838374 49091 244277 618928 424708 246811 304363 865203 638720 524787 414203 821708 390533 965067 157796 310186 577844 467658 55832 943697 803760 869366 412834 233128 706274 134470 576129 528405 299568 671…
Output: 810

Example 3:

Input: 256 128880779 554262 99054 72001 151199 655893 616158 900826 901457 953709 580547 846164 605082 10820 715197 354559 821640 920301 471740 76085 686384 921026 152072 792562 185356 370414 173644 330805 212228 218250 160505 793502 787517 342219 94649 679161 263612 146273 529148 102641 827890 264394 805679 958778 463883 627299 724809 370969 656054 415254 97220 272368 284730 559837 726272 339084 105585 723710 978544 712989 291967 351357 752432 144328 552444 495915 873356 33932 894365 492693 323447 632734 593450 19637 753432 677690 199039 353279 938772 173220 830485 968299 891456 978341 263915 614588 817786 951414 668765 44259 546722 735726 711339 229036 637984 221559 216717 529484 239006 314631 760795 218994 736579 89383 193915 167335 934159 821894 798397 435679 753853 13701 596435 116170 276394…
Output: 249

Constraints:

1 <= n <= 1851; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

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