CT55470

The Pearl Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Gail inherited the print shop at the poppy fields of Scarlet Plain along with its curious bookkeeping system for ribbons. Time to make sense of it. 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 <= 1246; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 489 200288184552 982650605 91031751 313348973 778451821 708511882 824890320 27606360 397077885 423653150 803336413 688898097 814669272 859092852 72794644 722044080 718756745 813821103 559782877 909328667 590570061 720556403 90662820 233244235 601369727 74960297 362978337 680668676 694082659 881639535 201557817 502589543 907536042 223733489 200951381 872685369 519244115 690273919 54296085 458782265 774863760 203325188 365121204 839779370 542711970 824254688 22521810 217566225 220259307 150263130 356083186 627611531 719026660 423327803 360789852 755683609 859926771 854274814 879087752 855967183 538778618 223883820 555006015 235445902 128109114 463800734 304003916 781064158 41840652 69643995 164081366 964387357 775382372 959347436 79340147 994194428 699160697 227588878 126638201 415432477 500…
Output: 390

Example 2:

Input: 190 98884159071 26018149 792916523 22092943 796880136 444489165 421114882 334657993 900671854 874583282 595933430 745585402 673157503 908101102 598607470 453924328 317258072 908228569 647350669 429626810 331216596 413335819 418395400 205899820 515256799 960133676 640058167 770289453 121660800 438156163 545400198 520360443 218230730 727048602 730983879 305696885 598455723 872102911 325520579 385887857 359677268 467446601 270809727 364959003 303735493 935202673 955545459 820822444 259531356 15029668 55338147 30931158 666545117 508843746 542847632 150964436 517255788 394429755 765085732 344063510 164430144 361986742 852980573 997340093 175017912 536789740 222284598 943962501 727391079 834655570 762927523 880187593 656880957 426487713 711886873 136919507 407751290 648070326 159078759 616923886…
Output: 188

Example 3:

Input: 568 21882361019 650495387 312222282 823721668 170752853 365968242 226180945 768790301 704951575 952981113 658788568 995971490 26487492 858324048 251374151 228442088 541089710 705595642 835123682 212345948 454255950 398581372 873266546 384612784 184783081 26605318 192036858 842538102 210001133 347759680 567938772 97593346 627781814 520302443 484306928 490259125 421802659 612217449 368471105 561400422 611612338 748919064 901158719 49806931 46081317 646456278 828123847 789857670 259186521 168616012 208247799 505390617 707764790 792552816 564759455 559292414 536595157 848946894 762687663 581059584 719263637 521447506 532465250 953291263 579303552 625459363 610077216 96601887 693655584 467444161 578694096 767258189 197678563 970475021 441361602 977705577 808685186 428593750 280729590 72464195 1…
Output: 36

Constraints:

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

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