CT53062

Kian and the Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the forest village of Briarthorn, Kian studies rows of panels entries. One clean number will settle the guild's oldest argument. 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 <= 1355; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 210 31666572604 478195636 516771536 392280563 741668789 206615043 394773171 778228294 274980877 130193194 941477526 273095762 561853791 654136338 908425057 895351864 512972169 539220833 813002169 105533132 3729020 372397282 294453755 113386987 247772990 943469825 168670142 666433126 555577190 978601345 108515838 189539439 348100744 473008255 532070448 661652959 900443082 115366162 60865246 687101531 382351632 409403542 726752253 722061177 180366898 391971926 451653595 651221616 185617875 229348700 945704930 811431595 204543960 534444897 122970313 614031561 549376886 494177094 924419804 14974153 934423537 258049614 194237916 853069100 709015188 636857455 663603630 713669475 510521824 222919504 930435049 671027539 230602739 658324834 119005092 754277913 795871305 482833364 132209539 12939902…
Output: 58

Example 2:

Input: 1290 25287861467 221307397 373010181 47580772 612077932 596090140 868654 517204861 678274848 165116072 94362058 700946555 908763657 619792816 923010889 837125148 17529757 66688248 508988558 759789615 845239764 484056671 179254639 112094510 206731195 239064042 910237116 129882086 322733316 724272074 570115315 771663842 816752206 46656865 834841573 155056091 251419571 952148351 936910249 37225119 514135411 526568560 776308765 572640751 524181431 798870630 361551613 774037943 92090240 548768867 67552619 417890589 577865479 174305136 34297412 709599813 974002116 834864123 681090719 26287628 506818524 480354038 301273167 981248553 250004663 830649551 224196584 32649491 631668286 174928896 156573978 701068095 366333341 505645851 380646752 658168509 308535938 598635722 670726011 505856788 2045760…
Output: 41

Example 3:

Input: 632 192584872858 545742700 844266990 655353355 606025552 647414048 413719545 121198110 615565686 953686010 993301173 372932556 788828801 31287004 562356493 364194612 260757677 222107350 926357286 49091099 196218948 440627950 3784484 436894527 410938302 70831858 975898902 210248075 120827424 254294769 176560015 560874120 393568952 372638999 234522147 224972132 782610064 810904695 38328565 214915979 326900402 858673302 555727408 138270768 550431099 225717687 242209730 534269685 374666603 767191919 835849647 82348970 584479506 74940088 554711422 36451757 287502813 848239660 470816756 58350415 989153020 359064324 703614862 414745215 159564120 140175498 426861589 41658069 433776431 70480187 679327752 433008337 305491096 199950714 304503921 33184192 305361832 149355839 652924489 757662152 463384…
Output: 405

Constraints:

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

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