CT38290

The Deepwater Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the fjord village of Deepwater, Xara studies rows of panels entries. One clean number will settle the guild's oldest argument. 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] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1859 262969744 847500 557044 251814 270273 38742 147984 68869 206184 941664 102845 639494 231179 665358 105253 345241 751974 361990 238306 781753 603823 545855 924386 214933 634087 299700 465377 972640 808100 565715 429117 634863 414830 373836 29655 400461 960345 695710 576045 558776 440002 659731 879529 280306 281272 232101 870644 644955 373656 43806 66453 216653 837256 107698 534281 60571 920502 542511 368080 93480 210061 344121 402619 554015 138872 478444 602510 435965 532327 316944 700604 184104 248932 258162 482870 159160 803170 913343 20209 872726 449605 403328 754827 270152 132130 504867 270914 439415 451905 557333 765278 524641 242723 977416 816091 14357 77920 345296 37391 873206 865745 6541 155420 594366 289573 351131 251087 176050 908757 696110 801978 972777 274356 959444 284044 …
Output: 483

Example 2:

Input: 989 114667074 220926 124556 268236 747356 725395 961721 33230 111375 417839 239107 436350 10854 749155 568316 386434 727092 281279 177214 892135 693009 439447 637395 472468 484216 547405 343813 677530 884487 699459 480684 459759 13731 176670 411265 545201 210523 130108 150699 209350 614235 4780 472400 135498 566767 107052 29878 542124 817284 437468 775031 965572 366358 977747 844739 199694 257892 602275 811763 284130 416965 446740 560724 896751 487801 657003 37275 194814 943639 605027 904654 817358 639577 548395 503785 887765 881826 6948 527839 431010 45758 588770 591086 951419 800603 220318 926461 343841 78349 471490 271118 653553 228629 367249 908234 492342 26518 210370 310831 712595 332551 870096 214573 863370 34881 242103 684785 475935 333411 622350 561211 594151 461170 30630 751675 52…
Output: 213

Example 3:

Input: 1867 558062510 968871 113709 153062 889722 365264 514142 215759 887243 455193 56107 868517 608017 93198 457891 410716 76457 834401 746306 210620 403966 6042 471770 995420 981969 460165 423610 822838 575308 186610 532597 638898 86977 117531 377216 248754 761626 988514 155716 529397 169183 156649 233217 159614 105974 535217 442083 924415 982198 954553 750123 557626 683534 754174 402445 12591 914654 923373 548015 511922 997582 585012 254608 518059 255457 541150 236078 855237 76565 599369 743728 426884 91638 51208 730089 835620 811009 651753 241598 546876 214211 36390 87552 215000 527233 265882 992293 666211 470554 75624 737627 890829 790275 566861 931451 111471 788986 545170 460787 829368 787564 853964 242445 809095 607720 287321 306878 368255 203660 516036 411662 464841 180799 636310 41716 3…
Output: 1063

Constraints:

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

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