CT48219

The Tightest Stretch of the Frosted windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Petra runs the boathouse at the singing sands of Echo Dunes. Today the books show a list of windows, and the numbers must be worked out before sundown. 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 <= 3300; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 966 50458723726 678007279 391273508 218746955 714016177 817845101 575817926 509533800 877144491 582343595 486011793 192839503 431461746 732294627 321541982 564462134 42890817 630521235 780529656 843085328 821282511 12480360 50906877 932014830 575012504 384605763 628197934 775862313 301569634 520729942 217038441 945242183 862749294 154248959 218312552 689955191 376033729 442445093 148175174 344040924 310095121 549085496 919791386 3830003 981678752 19155490 299770229 739374994 217706803 820950995 140590687 337074205 424628020 757275053 349683294 838282084 346342311 741720130 170340120 102360252 123492546 50841020 463052307 151108822 313547163 146245964 540080783 730995242 931988721 240572574 280149710 603544963 880488022 473416720 510895078 146332642 545262539 316666936 701498298 673477152 3…
Output: 92

Example 2:

Input: 2967 194746960666 423727751 721831956 343983254 308084807 921317522 648950748 182144778 934964075 845466029 390209305 279838879 865348534 722946672 596845541 992703969 547794438 161330036 589477456 223773780 94744803 788381796 216869673 275329818 494194273 532451238 496594484 132330250 857675344 694175441 358699508 321905781 152474472 82839135 532135810 980100049 715875916 384794866 859101403 462776496 923862079 906835658 537207347 382832075 581592597 980662494 318397772 963726476 797516715 233646039 445113379 164359944 425061170 326305136 632805070 701591763 230135835 562628777 240656243 167803067 80019631 879983533 19581029 38991827 993198742 2950343 979326373 145291843 682756402 173316111 398349334 551055738 850628574 831972164 208613155 243497511 432261015 869345245 733442931 73185659 …
Output: 357

Example 3:

Input: 883 250569442695 160513793 945075245 66757350 710870099 394850216 844663498 281061015 225244845 736703098 176179564 482551140 327890132 693884271 446361468 617166264 61284558 662889295 749323055 276981441 485467024 986958593 510837379 651784266 625291865 90642650 753150178 775417148 398861909 633801784 181970801 493455585 622860064 77844223 918731701 401447283 369402935 102340900 748111825 965389259 420952763 497124281 733283446 896512513 149756242 69287814 839073863 914621338 305124075 658116013 95272925 623889260 582670554 132832105 150770285 459791541 744922841 295634677 465220304 583888192 608376605 547768778 568355789 959950247 500016003 288828396 159643332 240731320 788933698 523303323 274324757 934513849 237372083 487859845 142466810 809972248 660298572 561371989 13695758 370128878 …
Output: 473

Constraints:

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

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