CT42900

The windows at Pearldeep

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The tallyman Felix has been asked to decode the foreman's shorthand notes. On the desk lies a long table of windows readings. 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 <= 1421; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 358 166422075116 865912646 360730951 425858682 813351891 365705672 842738916 451767376 719834409 355192785 975974182 783853858 419737304 78685105 63321455 730023800 87935020 580737230 379849035 356737506 68830796 887058210 850281257 902473768 651487613 808662721 874630822 495395564 424499441 409455891 365866151 734056812 484880738 972819829 677351326 703345339 482308318 758487127 578499912 726034877 874771898 127237821 948226972 517329521 295154438 914117147 696424898 253700786 139663772 775792017 309984984 138215062 31167438 991019236 635742229 949075024 101498101 110814528 109720051 25036046 809306784 960304175 470483360 494086068 682938591 531867252 524074098 701686779 879988546 357871503 846889491 610928763 372866204 734885058 573491813 456746289 737235538 755689304 14798777 33208799 6…
Output: 313

Example 2:

Input: 1295 591651913279 455241836 271271883 214847624 74318965 286251179 477814127 510739359 320850810 876808496 698143821 962669334 389867039 59000532 11193513 763765413 171287902 298939335 890110290 122287191 374521050 728558441 295638296 331192977 996174983 135172014 780983368 741327177 322985617 406244054 651384905 212806545 238909768 987598109 764835068 168047591 447083476 890398811 899095253 697078264 247792530 16970589 241934269 304907796 775003407 29333897 706594280 495768544 337125056 871493893 965961799 831008186 559503334 119593293 281914068 418706967 23002443 270925150 77871361 481596030 103559269 512813843 338552342 553562842 720198884 555407960 517070704 523776366 535368346 242870013 296883721 294492148 31103524 128137598 502478423 174463022 116281657 551483846 445930113 189641060 …
Output: 1174

Example 3:

Input: 793 211898443879 59657429 531008059 948704282 466248985 593829526 107953206 644881411 41202488 95532536 879860285 255243608 891505356 127574198 101238051 178573404 559137793 823597170 398685115 530185475 141330174 165024945 285874731 67711022 665064379 224895104 155399376 429850699 272620913 173343979 192745168 869908578 569242909 414188897 46044724 846277412 787442418 81708772 692626245 702074175 602361182 670907315 752329658 711874155 464356139 664549265 762002115 40065406 743154700 295195630 752173653 517393709 293213202 277603721 289471061 192179877 760631598 579263105 20428247 389092473 913731322 356500301 614195298 275641654 812205595 564027116 198361721 482470300 426043644 223034286 727459048 906140377 687345540 36213241 8271446 391328623 391959116 379713091 353030844 38452374 97913…
Output: 407

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The windows at Pearldeep - MEDIUM Coding Problem | CodeTikki