CT47331

Kavi's Ledger of segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the honey farms of Buzzwell, Kavi the dispatch writer keeps careful count of the segments. Verify the safety inspections, 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 <= 3968; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 141 72815213 122699 31985 427861 919932 510591 502011 767750 132230 201747 700489 626826 795390 924896 7058 167188 860294 896016 763510 281412 955600 824789 338738 584395 138117 737725 459753 210293 861054 541871 34452 978724 372443 835498 743755 787903 521692 137017 62456 367602 360534 538587 744142 862221 855234 772172 87686 957816 610009 691058 346314 482833 617679 980970 431807 188790 108348 625038 685899 355820 450212 709520 676061 880707 777590 645088 868796 971235 555743 463834 623636 909234 145718 304119 873748 448756 882797 864607 658998 952694 588943 322951 907509 649847 739888 128752 467284 489857 717527 939114 441683 253785 839003 221704 65086 393599 718666 260164 466381 157397 878370 689225 924021 156061 574643 504905 624272 821206 462726 201043 81237 516389 730224 762153 8480…
Output: 132

Example 2:

Input: 3470 1112059892 20525 630474 979902 987059 401434 313822 33699 310226 427906 36623 46871 873466 278848 500266 584797 472033 610731 952701 899813 101658 555590 350906 974940 685301 850604 277768 400587 506662 890093 672584 183541 726553 983211 358696 444973 492028 136666 953380 795768 395897 749361 370856 181936 112557 452406 167065 550353 332040 628843 863366 160162 990675 856905 557275 848612 175381 245461 857342 740856 905160 318246 509594 285547 92830 950324 823613 50364 861765 199984 519627 371844 904356 14580 980583 282447 195743 738546 309736 384504 230840 281891 426783 973597 763995 143731 414440 5767 392539 599134 247489 23758 982930 455942 452226 396082 307933 669491 410344 807769 673107 536921 200724 989999 963639 216344 278773 836235 214191 218665 272792 944823 98805 713836 7324…
Output: 2188

Example 3:

Input: 427 21231313 507803 780181 754450 623666 277893 938558 340584 49221 124458 570420 126674 390736 761230 839534 184268 913173 879091 153056 425032 453070 787993 250312 534310 3058 508361 882420 407626 545561 457915 7837 834357 327778 560820 372251 695436 258670 675719 346882 288797 928104 238684 276839 811426 982027 139730 812391 708275 410639 946311 693731 990113 366681 25114 162037 835998 543197 653532 346820 463362 478191 297614 120666 21760 712422 87406 188653 10450 372949 153176 576275 403794 976631 38911 198579 329986 781640 843298 539804 510196 936814 487632 575451 913378 739290 823229 789310 346952 851529 51478 615536 979274 441107 606012 588285 550791 21188 439208 508019 156255 260473 605898 182640 765270 351334 947311 750418 913869 164334 483501 501758 193232 761726 294735 450782 6…
Output: 36

Constraints:

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

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