CT40145

Last ribbons of Tara

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The customs officer Tara has been asked to prepare the winter inventory. On the desk lies a long table of ribbons 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 <= 1415; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 385 28453182017 19136918 109873772 894278073 355016437 551508898 527817418 80501303 776328283 731037182 692779245 114251607 201091582 643829914 441303097 626155753 562982106 786548615 173909508 199292072 958345238 470991180 8926286 831458762 175689028 601337027 360458215 480467842 227474602 638248142 196947596 401786351 463744672 620807347 491890623 148169170 800434379 314513668 933608936 892054437 699467664 312783348 996889115 41526821 743802369 782274624 647178675 367319958 227509811 123092768 802377235 888710230 622633702 198545243 506247847 32079753 536414724 454571479 210789957 496259378 479048520 559247972 11281378 568462509 395849477 360505135 417464473 638123942 505671667 438422061 192349973 428752173 929772132 103201739 190385484 768648240 717031357 436039680 186663904 391490103 9…
Output: 46

Example 2:

Input: 704 125298098993 574541747 727041301 979741472 415284626 5801711 806001995 333917411 714671741 288458435 140783427 662971627 154921500 851091767 769454790 460138655 399076434 790952897 693830604 713640598 58467099 284136279 645004879 128768275 871157493 336848372 524061274 392946935 663512091 481245016 851326801 460427032 109047439 980061430 747739319 742576092 119399069 137649566 520033422 122626389 198714914 707400805 312444166 179398608 88611717 296903393 766914230 978347400 89681788 57489745 583418126 386184250 984679187 308771186 164393811 993971632 748034366 822480973 242720024 934464553 720735721 608172730 801489415 209471041 839660731 353363807 743542699 159874524 406551792 30014009 971127879 932807313 276801409 745839899 63412058 900610609 756482596 870679601 664651048 218633274 6…
Output: 226

Example 3:

Input: 798 364301823394 984949882 585133962 395655083 81104943 364196839 970271094 859647779 834360173 992527311 209589092 733822748 853814049 711858058 49224222 722699319 247377574 284169527 526505022 255735009 626478490 477264924 234242667 580066945 120836778 298871211 601365846 324733298 624406011 740500496 183731893 806546467 311139012 809209617 823281883 617584026 920213377 903122930 486505134 562018471 465820227 184463701 803338737 904251963 450037824 367547060 138533254 940095355 470027325 445454903 43757824 486082843 733664462 657445311 324450292 498753711 294012180 310589772 592081773 546024730 214075031 602836493 706944599 61049845 963626218 413367616 486470401 927458616 103274258 602384606 8460122 991668523 705172782 20379196 768239202 160139839 3557563 459007847 91767236 19099491 4941…
Output: 744

Constraints:

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

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