CT39628

Jessa and the Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The inventory keeper Jessa has been asked to tally the donation drive. On the desk lies a long table of stretches 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 <= 1481; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 613 34043123556 921227955 255326405 139708796 238312964 136093021 154840502 237806786 227858644 253989962 921111082 924941087 467130286 547989974 744868358 893098831 721375228 496559669 895205758 712188489 133344520 931367071 341218614 821382822 673295819 505541407 2922770 593015954 471429970 173654038 38616359 463348894 813186993 374910501 813083420 607857678 436917034 677470607 863304627 535098562 209468474 191574747 575407299 897922689 844383115 516473489 137681745 433743129 99133178 970292599 902402952 112126862 505865953 878083211 640647505 183998937 880533409 95906393 524445489 871759328 897280149 477361174 654973852 676689816 457319710 162909332 84122025 364396950 918126871 737428830 209155579 261358071 375706414 177049934 642390569 624416929 16118094 841193520 120766766 929519869 9…
Output: 61

Example 2:

Input: 946 224816204 465505454 24028049 553571338 463921729 244450657 15037912 480276944 663277830 168063081 298975709 936994687 182953003 856882632 731461605 417185591 121046531 687965984 243270475 395516635 699206747 482858853 948846150 55104344 932014605 782983923 621995312 351622676 144017573 293612189 954921349 44046452 462317179 86118179 815403276 607075002 210158134 660141718 5979208 2143023 513640468 820406616 653133978 552537089 524932070 367120436 413005195 25469366 289021031 202072821 232063964 696635534 691343286 190238177 819228768 83034291 373539779 178598454 295453525 661645337 800597428 303267808 508427345 411661263 821442291 978814251 837372849 57335277 769807341 705047070 951262680 537302936 446867822 65860158 592909393 881074681 872512973 180325075 850987702 682257602 159678380…
Output: 1

Example 3:

Input: 264 44622406857 698765608 356605103 326142183 290033402 835991749 850640874 762190844 502742732 827048048 479748324 863478305 802683824 970736997 698667000 179756781 474570875 188673197 660024648 781132148 355917669 452741339 970051598 203850880 733603011 969891283 195261621 355364173 473766260 124612586 738285974 680894461 604958496 733669990 279154882 343789514 686110614 626368236 257936331 833732770 270387038 554256877 482550281 949270377 699693691 348767517 684102635 335683293 269173315 976786034 528505159 159794836 892543399 838516295 644573026 878927784 945826788 388420262 417752572 914254784 578159159 872844707 886355859 926630614 838340483 738628401 798864228 676901738 368924172 487767234 182716670 768365095 279257509 668939184 647616484 841209275 358178639 606252915 160218333 6028…
Output: 75

Constraints:

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

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