CT37784

Blythe's Moonlit stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the cinnabar mines of Vermilion, Blythe records each stretches in a worn leather ledger. The guild wants answers, not guesses. 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 <= 2085; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 1051 141663763879 674134801 898818462 129097771 986051760 688932480 339813673 172564369 398790446 877609015 700595231 691857922 883104481 739632188 801792121 318946984 551453389 483473820 161621438 476607396 365191183 108835725 179894512 727043724 238920166 630987818 762736977 187923668 657018373 681587378 986820086 394019882 877235629 179773608 218872306 20171552 63803892 186438807 873602244 550428133 700871196 306185013 622345982 114619986 937375583 476600738 357478433 485213629 632386341 697501303 75310533 551136536 712550686 164740187 140245801 310724659 418500504 118855090 148131601 158098663 185330127 667320033 276522430 568479872 590190004 317767609 683106873 268775707 895443829 752317055 553722222 976526642 647239115 52589012 453191350 738371545 349769612 788764438 595451396 504797…
Output: 272

Example 2:

Input: 497 147940108757 861951592 422956298 433634265 334226417 824065066 350174911 954237155 558555703 452918449 474037526 633605647 67351383 265391609 979011961 486162416 598021590 494152335 870636387 698277717 623169315 119667567 896512987 417290618 654894386 348623336 112167707 787114979 699020142 720363143 94338583 43373650 700144271 982515361 825493254 536820039 424580084 908564906 399171068 183149064 407644020 615099474 129247798 378892557 317666692 688973870 101284316 403295447 126958879 87740204 450663811 162574410 764224023 118894054 978298385 237014591 945153052 171558878 67341092 755958604 132961166 884208917 417708095 724947220 526034206 934367038 277699179 889932476 116362798 840213155 930916037 758283700 196856795 666626130 722445843 544218587 684911477 192602551 734191646 66096365…
Output: 298

Example 3:

Input: 1280 196330257222 40457797 783774475 128276807 279038161 331544956 437641597 471790421 481166844 754831568 246931158 930655476 428078412 856038038 497816364 705874558 119550319 337703764 404457010 251554071 263108359 934569302 715674141 863226938 77083719 434861908 601910642 399173951 865127838 273134257 587999347 128187659 181673175 873126768 331164970 437301695 281140178 148055970 45921014 991965121 726245937 810121383 279790221 353694266 890955254 142567240 357730916 622047279 935150622 30515921 618400240 548023917 612485988 212630409 112241106 683935843 617328888 269479444 264663935 653285238 583993782 138320526 956799455 533338149 806518695 950436392 793084878 20256275 933635979 223475803 836544129 318191996 892799709 927788881 260941874 22423215 685531472 833510552 765236990 43291901…
Output: 380

Constraints:

1 <= n <= 2085; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

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