CT37966

Ishaan's stretches Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Ishaan inherited the bakery at the mulberry rows of Silkmead along with its curious bookkeeping system for stretches. Time to make sense of it. 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 <= 1527; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 597 170378836 478728 539431 563819 565068 106090 598610 941716 447313 873632 586492 555575 270557 978423 352914 917817 423381 118278 380136 566984 212724 949001 717149 866748 492168 419438 270631 758618 191617 253283 899951 833828 312588 146011 989920 124866 753208 825937 60663 56822 66310 261974 635187 342430 339690 28864 604668 769611 483740 712129 667123 741672 269105 341470 571480 658964 463039 605993 434645 888181 448399 600233 111475 352803 121989 784067 458316 869971 368984 796047 329596 86756 372219 580176 533981 202798 534717 945401 625645 561276 723150 719068 586730 504242 772902 325430 209 351185 613196 330906 433565 828135 80999 533405 338429 63904 559000 481383 910680 161388 726133 515387 628542 363493 563206 808921 730202 992716 117681 601678 190089 416537 511543 811160 13089…
Output: 331

Example 2:

Input: 1216 473007781 798044 317744 102926 347117 253423 983637 239680 880695 620002 620020 351358 809213 911382 954430 18758 714660 739174 819708 611431 2640 181448 26132 705859 105167 158248 835757 791134 749361 109872 336332 531664 479893 284965 55669 125514 89653 650451 485312 874318 535218 335541 145010 18585 544687 121914 57242 509795 64779 624129 261287 964780 436263 351487 547400 781254 571482 981680 334650 885189 621458 63240 817074 994141 568585 294097 779966 833493 326501 250329 744394 982254 337452 920504 980896 942187 299391 690932 516761 511418 985361 716577 513978 576574 24275 39907 440198 519518 422892 723355 828868 913859 329769 28016 940207 213487 512417 492462 36227 18759 86420 220603 904122 638398 315733 84428 146513 195904 838997 537056 452747 916986 618556 894684 716835 8674…
Output: 904

Example 3:

Input: 1062 185976306 520682 667851 321698 781566 208553 439601 225204 422420 8259 876163 493593 81834 296823 282071 510815 904236 493127 651766 361881 847762 650556 176508 258452 484857 309825 814388 901317 617770 837757 39918 633387 903309 720020 924080 682818 177786 515111 501229 313898 613741 489242 826561 355501 344041 647800 570456 449654 539113 147767 205834 635013 335850 482655 275477 521520 994337 831866 184457 28815 235421 645162 24482 947610 364258 510071 2545 543199 238617 262144 775878 607119 88184 511244 517101 644390 577809 55115 191997 405513 500569 686360 690012 467592 771284 651718 877941 264419 307512 361437 509206 864372 821575 472215 833637 295389 411101 402373 397549 294172 821646 159360 176942 580943 655417 792199 744637 623364 802801 654810 86375 733218 274438 285852 45601…
Output: 358

Constraints:

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

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