CT42352

Tarun and the Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the bamboo terraces of Verdantstep as Tarun unrolls the day's manifest of scrolls. The tally will decide the next shipment. 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 <= 3617; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 2820 462650468856 810381394 183559267 935113698 996354444 18658616 815097133 455545857 775580221 288093560 13109108 630376784 614373869 39189256 930925628 898516115 220243084 525044885 983556567 44931933 730639086 985311966 572727073 976984072 537202746 686632060 561346290 528643113 5059629 356620114 26963434 325482984 574946429 799832093 708320751 440577860 957537293 616209009 331640223 994003669 653631397 221359956 814895233 151014442 774964753 175269725 540758296 594225043 536205960 601411838 117660325 810854206 858953202 428945332 976300363 334722483 910223225 133134030 509588887 438986899 819821343 841524530 151591103 436089597 352924136 526663397 516585626 224215073 271025851 319516181 999203906 261398330 125438230 647899083 620146883 489156413 68901603 794352282 214104815 925536739 …
Output: 905

Example 2:

Input: 1310 258050162292 731142457 360886938 298492360 514584043 521969143 507671100 657127541 373061945 261034454 559136772 59572998 751752108 75967814 494172665 124146031 829216021 517177034 934108251 708586254 324383964 938399904 677305482 250197876 470279802 244011016 670181242 89800126 341272549 879230939 920252912 146517060 959610417 115737171 953412328 995508516 942144308 375657577 498634520 610248984 616122236 836250838 454611971 713274060 712608084 430346970 614729596 495212410 87698814 661229076 430151306 307870281 15681736 33316779 379020597 70667153 842626906 445969505 609021760 796630324 932695221 639279658 448428244 864551471 166239694 374635747 811132016 108032252 909968449 753440435 563255541 921721764 788309759 127420 739060943 683017777 157962592 350618705 942681670 803731317 11…
Output: 490

Example 3:

Input: 1414 691692069912 338852730 369309445 796320676 87573396 587499154 198929978 647300590 698249956 691795099 38414329 736865406 356329771 17569338 337007722 601534733 591980946 825477093 704433207 953925793 500216173 633720360 388989009 900474667 491980255 896329316 422837743 971200205 311928224 622216015 431478905 698701429 736650305 257274435 870359286 742105120 609537166 656010330 655606272 646373468 175045365 891054967 360953716 924236689 730556163 295187983 47999334 187810015 987349513 113280717 218893690 240718077 15072595 599389299 94684302 547612019 230091961 797790822 157985167 789343123 500805069 640139157 522191422 579898079 246300372 732549870 617004644 756741985 999034679 236369786 835575911 377994560 101614325 829703093 750251722 146112977 678614720 321534262 456226034 66644396…
Output: 1386

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Tarun and the Tightest Stretch - MEDIUM Coding Problem | CodeTikki