CT46954

The Smoky Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the zephyr cliffs of Galeholm, Maya the inventory keeper keeps careful count of the segments. Catalog the new acquisitions, every figure matters. 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 <= 1395; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 806 258047931 5137 566978 936743 620438 246500 656489 624998 764843 733607 657661 902746 462205 618300 198454 469832 144211 390152 84558 435944 57509 295477 153472 116685 258430 5084 107036 634630 864145 816085 993495 56393 693604 397165 971389 691399 48658 318392 304011 569743 36397 303202 35670 282375 963064 196014 604486 771257 864251 256110 855978 881224 424263 407981 649230 467952 220567 601090 677532 608921 628168 483137 93215 820051 359735 933170 323444 153951 943539 402274 267058 977789 133130 863708 228411 100114 705765 875296 895811 914731 780768 162461 437615 164203 170922 653040 855442 716332 922801 663932 889685 694009 918036 597935 14336 246264 527989 398018 540519 208235 981777 718581 606826 604114 182373 971797 406253 705972 314497 94193 812390 567119 782647 806218 644470 4…
Output: 518

Example 2:

Input: 521 172752294 965713 218844 818575 496526 272473 144286 761432 581395 72675 70098 778478 16667 657673 809211 676735 593518 393026 528169 965689 50407 961061 721424 66434 668850 180064 232689 845716 506088 939424 276004 192467 744376 353306 869751 437328 768553 723280 259372 764479 697075 500545 741492 107818 263916 418831 687892 309398 251495 432172 876198 734580 469251 28860 407359 529471 180042 389382 862987 899631 295035 161252 551075 394230 351304 711591 422723 924640 10486 694697 46182 758017 927661 53027 128578 874038 919542 625239 852786 887046 497342 757594 530088 315885 836814 278579 562895 627839 839219 151680 241847 62609 142902 613423 366177 770289 425410 49627 449619 777833 220701 897949 750146 920161 13187 990477 357997 18843 631608 376199 426512 248022 508761 805675 210728 3…
Output: 329

Example 3:

Input: 790 352227204 645397 744208 2890 756741 564160 444049 749269 614894 194717 289588 57157 69069 461605 218229 475437 313278 30270 622669 38155 682272 763685 625998 584859 364752 773770 626115 290593 6712 674530 585071 505279 943062 903314 111140 433711 639122 151639 591323 311887 131781 145883 837569 771378 493305 443609 533680 469203 511761 678024 799742 759692 573011 768968 76497 980313 669817 839466 765936 237729 696858 432573 55046 568043 33027 821062 805930 616425 208900 498604 751330 235765 90779 306529 141571 87869 684030 676050 3398 850550 999997 232991 388804 138008 455372 240685 602993 562186 19699 910050 654363 416335 808991 979607 310766 627038 389168 353907 818606 510495 756238 545141 465632 129067 744707 343242 456685 199965 987769 41507 773862 266580 410952 73326 96125 687033 …
Output: 683

Constraints:

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

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