CT46273

The Indigo Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the smokehouses of Brineport as Sage unrolls the day's manifest of panels. 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 <= 3548; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 870 392763808 440151 191664 581681 74598 876664 987270 831248 655213 903643 410403 614749 766293 186929 305890 310558 301880 753284 679777 452168 499394 868474 975952 419215 549531 918128 2611 690455 620179 650511 417411 789881 899860 185542 773002 718261 233451 781336 472027 298675 218459 260987 742572 609419 795094 906189 883059 124441 793552 814449 788735 2292 771037 833132 981233 312611 127729 550949 777473 398206 196628 788275 910327 898803 600954 542590 484101 818387 11169 366062 98709 170221 375649 227091 810969 641523 1174 686758 384734 671983 163616 854606 757889 558604 636967 270798 942485 466771 413546 696940 791448 430951 644915 720572 224571 240344 641600 839431 637871 558560 192917 891213 701174 549047 123541 393967 810653 478586 694180 171400 313639 799166 296891 141260 7065…
Output: 777

Example 2:

Input: 2121 25685993 51734 203191 759281 382389 443885 287478 236858 259484 637518 749639 65592 753103 305377 463465 689387 544901 602140 361311 636087 246294 527136 659868 948276 97723 441703 559924 975934 960973 425877 256026 983912 400971 225230 831437 813658 832559 861260 418160 268965 893102 583092 476864 249205 654708 717725 459460 908543 335974 990146 578969 904016 215126 775574 663570 375085 341064 499237 937560 21796 239889 559376 357819 848061 976215 307448 3034 877681 57256 505555 117323 820119 36972 100863 944928 585723 458264 409898 541104 41698 245180 197977 418470 390268 634218 721920 967146 285264 694356 566910 656749 492392 149410 972777 178475 643953 995678 594970 703675 71530 530630 643052 504199 70568 157820 591121 480958 626269 767637 718950 895330 768616 191667 463866 552680…
Output: 42

Example 3:

Input: 1931 296708851 105310 923661 634888 263437 146232 36900 897195 620485 982912 604264 625077 793129 692639 508913 638720 379365 365578 569304 852160 598277 344385 880911 938121 615062 421635 96211 408017 81278 825096 586444 537318 790080 841092 280736 749002 290020 878193 234794 423655 735218 908415 606819 978637 622420 448653 802472 358594 901614 288047 168893 51107 163769 137979 740049 305527 446615 969664 858739 185609 223212 456773 441268 780567 138121 247950 241967 99105 129916 740413 734119 882063 182454 291547 17060 785744 403513 803441 821368 209799 767855 547380 410293 627637 857962 299585 946941 844219 605144 184083 761764 301921 847466 860806 836889 934686 307458 236721 164487 814819 145860 275116 578101 278976 635761 270233 580604 118537 797752 555524 942926 755296 711058 567786 …
Output: 562

Constraints:

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

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