CT41200

Elowen's Tightest Stretch Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Elowen runs the ferry office at the silver mines of Lodebarrow. Today the books show a list of windows, and the numbers must be worked out before sundown. 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 <= 1249; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 387 47619470 217002 890835 718975 503805 665441 724294 654179 290382 982312 88994 459773 411476 830299 876248 996814 718985 526945 273196 178492 390399 480075 53903 492958 725792 81572 915109 284949 154227 296777 809436 121418 312686 724211 432982 998178 578648 891521 163343 438116 73649 614300 261976 42352 134630 616022 379106 466520 879581 202054 895732 32874 212573 547768 655937 311357 182592 769466 660562 179273 253248 584326 152129 955276 473508 107664 593023 303575 685396 27816 513710 673430 244886 965269 515303 192055 778748 439321 453993 271103 473514 401600 508865 337340 426582 234238 153881 284710 675078 796459 719029 712348 711118 268280 474218 55025 300012 261552 245550 907765 575794 641825 583443 191102 202100 289443 371285 281756 647397 279502 530684 506929 164058 631206 1382…
Output: 82

Example 2:

Input: 627 149323745 331362 813916 927871 339544 637775 904091 827592 270645 394154 656495 503697 911901 950278 520118 712722 947026 456501 179072 493458 200157 334605 526183 700376 887894 79848 864145 159670 143311 46838 421683 922557 635187 702035 672485 969691 920089 391952 318552 253365 859039 197063 186948 216421 739454 876919 125326 823710 140247 362799 763986 36779 509855 870003 669609 878657 752129 536563 644842 829684 164681 362330 646322 101567 200556 775162 76389 179508 316040 634155 276968 131667 619620 892831 377970 660229 880391 785801 425393 528570 913927 720366 609089 748709 940230 7544 729410 816408 888676 656450 367982 94017 292961 962373 477943 488973 700067 296368 50878 8390 321057 929782 409659 573240 648126 847218 90558 411865 501947 873444 533067 778276 652046 557990 714049…
Output: 284

Example 3:

Input: 386 176121685 614800 495265 953833 321165 848318 510622 980130 938209 344702 719561 413481 626181 927043 280240 265270 932191 339378 633062 883630 695636 101146 817304 45645 4505 500798 626305 878458 831068 199534 682336 460146 440976 415018 563365 886221 728728 581056 542141 665885 534227 999660 257845 893686 41089 761354 818583 44558 194311 107583 109609 283842 796690 656879 150722 493028 8031 455728 680228 748414 603709 228567 504822 839037 421471 272121 895072 468259 113166 794483 743209 753418 584033 572517 659260 455218 286538 541454 654956 379544 119862 991316 880778 105878 841124 174814 935774 491467 222081 785745 817249 539533 356355 51115 79545 820502 756328 593755 463168 60289 973939 254944 247706 250129 18724 518801 912204 143654 599123 197352 705726 771577 981095 304520 795661…
Output: 339

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Elowen's Tightest Stretch Ledger - MEDIUM Coding Problem | CodeTikki