CT53722

Last segments of Boris

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the moonlit lagoon of Selene, Boris records each segments 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 <= 1853; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 528 172695729924 536431951 408575764 206626555 835039309 412270999 134441522 623680361 290692962 955292970 872009942 147032743 76573316 400567132 900662524 574644517 993679358 113950757 222407175 789049946 694243777 83631698 785195200 850198904 574268869 433739071 164011839 263687712 752037369 731421363 729362854 360383081 12241519 393993647 903361749 697343623 236909658 823314534 54480245 464615114 993981503 94865433 909359233 768347911 549766564 71085771 83499339 381292872 474169726 354532366 142089040 876969773 279172830 137269116 525097017 602274299 665179424 597466186 69708422 859848909 394668354 160019697 290553061 16493275 898256875 915553998 988029848 465096180 219515933 738691183 761315261 609207145 886187317 742537293 159413443 306545807 2367479 354960807 192840688 322141132 4492…
Output: 362

Example 2:

Input: 1523 74052340488 168086016 31636988 324461118 29779320 769573221 998267485 646071495 830884133 694634072 61746056 798234843 201285944 437339622 453404575 723043279 997058228 7021163 451987465 952609348 337595134 5111358 473262391 359817317 559180266 421794003 815273678 847954573 183810224 376936453 826525002 802191951 836707927 431373944 963461480 88456649 949911332 533591509 164644082 656843032 236358909 753238005 972277303 786520009 256436895 685704954 750391447 970232468 409786386 272529220 3113362 510949504 510944220 239662427 790693365 221560595 110928184 954477354 611517468 215113270 665724480 728099127 77009152 420335683 438047666 920766848 177195896 30458447 347520604 419277670 414371889 150319450 208051177 502869921 271143967 133907595 492083383 171429623 114738180 128468948 85585…
Output: 138

Example 3:

Input: 245 43506890275 637283660 341439828 508175320 440230097 794721825 644420326 747575865 1817766 682679103 476207355 839022474 139629341 20335572 149155730 193660498 562861659 770945580 14905022 681459427 909523918 480603519 464345749 647593359 18377125 716709659 535089478 337128573 123900958 883170403 470500500 106260853 651573125 821062238 403813321 510261860 221463061 592260593 169848299 222442914 63694484 629619778 467241743 719659818 671541150 76338775 791087553 976834495 131184628 738006965 946935891 427873866 934466413 586685135 152253325 729599488 933571448 506085386 362012284 763548548 929685862 636664329 910262193 296498302 604567549 348844919 664672309 641271610 275166271 66992585 991912202 174772365 226592138 392675940 65806803 317704023 596999902 341848358 188065292 705675813 731…
Output: 85

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last segments of Boris - MEDIUM Coding Problem | CodeTikki