CT39105

The Tightest Stretch at Amberplain

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Fiora runs the observatory at the savanna camp of Amberplain. Today the books show a list of scrolls, 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 <= 2518; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1934 602273621 504363 190181 469574 232848 986093 957065 613981 350369 584775 928281 619054 749041 728929 817070 461420 948162 480568 440016 179519 728941 313812 598229 827126 532770 796448 207312 178174 317056 762799 984833 159688 475882 978851 620308 569544 946816 554811 286709 843097 430890 664711 289814 163600 297448 432229 612660 823515 448895 148453 987840 485981 223267 583024 13240 704193 35528 651871 805337 426976 706016 847339 677793 380839 705295 556565 295374 780519 569508 292279 314320 188724 826281 835661 505994 152871 492049 144907 360073 995560 111273 144543 634542 321011 640448 689163 243843 229916 659281 834001 572385 492329 82429 934434 426000 551709 85322 215166 297216 432291 775266 281080 286048 515070 275060 860179 355386 68808 52344 546993 602221 606519 66222 246395 5…
Output: 1180

Example 2:

Input: 568 114721006 137254 633694 303056 628911 424325 919757 7754 862656 588367 873537 404466 95909 437345 618321 959126 15524 529527 317621 663183 171221 924786 230757 207460 8321 969410 440065 585154 466656 493892 502642 21062 67641 563611 727226 165835 439063 461929 698154 791702 578918 858177 862239 437420 530754 66034 620463 660020 216609 304559 157967 874879 107406 329502 830626 171895 675472 96629 738919 602540 31942 822334 457917 282359 594257 984380 839428 150165 531742 117616 469308 492382 884525 834882 696113 187142 905704 568725 138064 636274 884468 224070 523050 703467 79364 149031 414853 317920 361741 570209 567579 692156 99467 395950 605552 335423 858797 277583 736784 754949 739526 39701 916268 623694 43496 898129 395959 72413 179924 42201 652082 58226 62846 999890 708488 370881 …
Output: 219

Example 3:

Input: 2478 894123546 610403 312378 525341 541011 705017 762009 570111 502880 221084 334949 336232 702533 427159 92694 841198 724570 927341 11352 808025 992881 43950 658373 658085 121765 442568 952176 441222 450552 847305 372133 676657 990370 97809 378907 371824 487272 498344 934681 913174 922775 223609 815272 139908 485230 531818 402855 378473 257618 654901 749163 230465 657140 62063 588710 330503 361914 169508 381515 440087 645293 970318 6016 179096 593388 291731 285339 375147 172826 345088 907452 641269 502804 662505 777931 937474 217427 831814 808190 809305 855449 118810 696314 858071 203018 894606 188282 589785 431589 405383 660831 678701 206909 146913 923886 679867 362677 513936 270579 633765 477361 615899 375040 594472 64085 921326 71967 250213 476686 398356 910721 983177 891361 579688 814…
Output: 1766

Constraints:

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

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