CT56768

Felix's scrolls Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the copper works of Verdigris, Felix records each scrolls in a worn leather ledger. The guild wants answers, not guesses. 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 <= 2065; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 1581 740014223375 299286300 730073450 630900225 425997792 878382073 950261973 699812604 869589483 112412242 876777443 690966558 401899938 343732772 333587393 27966129 127239591 707355875 754800300 648162745 415877139 849251598 142580726 119050013 919875581 869092171 765963487 684254725 788229119 929734290 35694664 531427658 61660478 706592248 638046189 161146367 704475594 916851339 877205418 349997161 345325160 143686939 292450963 429491992 465001561 455172470 792694376 679993368 871777429 79076206 230251624 292582564 290757289 893277643 261145960 613148084 787213319 50702391 917901004 635502708 318443356 935314053 159871692 944269860 738326124 534499214 639744081 704767333 517940807 425916424 760941256 342513432 383557011 759560310 365393246 601632611 445948737 754760818 438031849 6126508…
Output: 1471

Example 2:

Input: 362 122166165921 778804068 476715598 254645455 93445588 126067932 698673175 48147743 436265641 383876730 480367742 453069997 635076949 216095533 769293748 450741113 695343874 15726135 767172742 887588984 675023937 635479956 713747325 936512977 270998212 602964517 68063562 636804324 818272710 594076434 807358984 281866856 735414378 593021854 333902 308912611 414383894 761123155 567804505 232525641 776342806 783158821 675675724 481353678 516199765 584858723 493370492 642312479 743921367 721525072 262543804 283941013 609603808 242565600 991516425 4276454 583002125 101711817 250118452 205254554 584580986 889531988 876926077 701178442 333558555 514349192 239408440 407031493 825271088 56030388 42333706 4438541 46407425 734877463 82411013 48865590 821647678 414194151 894164396 273060008 879608461…
Output: 237

Example 3:

Input: 1783 266834397242 184245790 199064764 679202945 616479606 995669277 811498235 923739511 324494882 309952637 959844578 807181000 201328478 316549714 561957346 806669574 190746688 59213189 460287212 713509762 979590301 498798923 594350682 360763666 912104537 995732598 758621997 676145618 645018035 562706549 752278471 720388239 371069018 264800912 915109542 541614625 601125532 285363781 920540731 517129683 558340915 130606865 424759390 850879066 524611593 790558714 272307385 226042526 396377725 380326451 176938763 717157799 349244565 28617532 741127876 64929860 373105940 608511934 976736570 552367612 442570390 228127836 955858093 975551831 70142687 574524719 62450361 512242751 179325381 871754587 616425648 91208206 81921469 510281850 318975 618375294 904208991 669578240 550589464 567531781 43…
Output: 516

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.