CT41204

The Tightest Stretch at Longlegs

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the heron rookery of Longlegs close for winter, Dorian must finish the panels ledger - one figure at a time. 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 <= 1426; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1004 200520385 40908 925693 507440 770299 26539 511010 752753 245721 962710 442238 147270 700258 582002 447660 146570 563448 274817 943493 920258 528588 636861 531502 947931 127452 382561 200983 872326 416493 802142 679843 580605 819595 672420 119788 715381 649781 930058 33555 586673 505546 167392 447761 118745 826016 274902 478981 926534 481674 658514 594839 898037 937187 276463 386896 369304 539526 945474 79524 489873 664701 444752 739484 494774 25401 71308 362301 427149 334192 395431 863102 598322 814151 924422 158551 681527 361468 398588 560598 338746 650909 778976 157068 971371 820095 253692 86655 913838 767286 455505 807473 81772 35284 934338 260460 373192 594078 497256 529758 351615 622506 30441 8262 401491 174316 706236 184748 621482 876204 987320 325225 385836 731256 862153 843542…
Output: 379

Example 2:

Input: 249 102119018 574370 502910 465604 855829 710660 774130 363479 126805 799566 311518 432752 36484 76336 470304 853494 985679 156327 930486 421339 459637 328918 877425 190499 298517 155668 461871 523432 48537 929240 35688 880408 882832 755738 48339 883371 311635 14237 621316 687468 360143 439607 18779 362871 633036 103797 499889 716834 323744 889281 105712 556592 321288 514026 602630 985259 698690 921527 883061 527611 924737 129470 174562 739678 951239 853185 648654 83299 985910 180025 841792 894196 257592 673324 521946 59859 534045 73627 140333 889801 205736 431883 240890 592211 833769 328797 690323 598952 192608 35364 455497 552083 824189 567785 488492 538593 764076 299875 904677 183531 847936 269760 326337 574519 248089 700529 785208 847594 147215 692806 555214 161638 755281 376804 546284…
Output: 199

Example 3:

Input: 932 15575827 468909 191313 984121 549040 691168 595024 359046 427813 79974 787138 428128 798757 829275 826040 676742 455120 647115 134096 59275 411601 145996 316790 959888 144686 631384 179621 616891 44526 47403 465170 761714 704895 958231 746128 718371 57753 506464 76312 955049 151767 878947 418447 934859 532241 600729 627247 165365 671457 89113 603265 914175 720925 777282 517803 894988 516705 563328 585537 951804 966436 394118 234356 745430 855660 475889 510755 981352 69678 476618 283643 615479 603023 828638 60702 442275 636046 37395 895566 877413 694205 177953 911733 821004 411056 67788 693134 297742 876994 710871 461996 628161 826622 361763 335226 607973 599243 988040 819468 920678 820245 722110 821532 22260 865546 173813 200643 151407 90043 324706 116404 178418 487599 599903 769321 75…
Output: 22

Constraints:

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

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