CT42135

The Tightest Stretch of Beeswick

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the honeycomb cliffs of Beeswick with crates of scrolls, and Porter the registry keeper must account for every last one. 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 <= 2216; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 372 32880818732 11917278 108250908 328419789 43081534 444033346 153171792 195396333 621499853 944220955 621060819 984304330 536509744 366442206 200217733 772011197 800861326 1586998 994754279 106006655 350002631 730410335 678178255 563821760 436400676 452843200 96938411 988918459 863002738 292271283 64145127 175350015 631102951 822708061 565332498 752468811 236366261 464493704 840811486 34030288 394961070 108959022 741319945 531438500 988677128 701912896 918186162 515741931 370978334 277434141 81563031 190714631 873915542 26409461 165757497 506717752 982272640 385097607 683462619 78856136 193451345 589624626 953044454 367163908 195904517 331157558 583312207 194355660 878882798 687298139 938631793 73021173 271938863 735040044 631078419 143969849 562779881 292431101 687463641 803665260 26869…
Output: 57

Example 2:

Input: 711 95444460294 854950875 310996211 694265004 892950810 407305330 98957258 209425677 637236264 227769387 605937964 7152900 328588748 874079428 577364666 483520540 691688053 882639080 256514691 368098386 308050801 144614208 779958507 372438133 543406240 95051537 355748899 604417193 112372738 966774216 967217354 535802144 220041210 792849853 497520544 656043708 542898619 11039941 174636913 122978858 123807962 969317419 478748922 696377383 120482582 595332117 198120813 375957697 371083145 548748544 966339541 210745749 885362707 751176491 235608967 788407183 863408195 476435052 462588356 705126255 92864345 552519826 197588723 191319350 465773778 598292481 215699112 673434330 533999532 983376282 751954787 154592466 944713069 256553165 996514092 251062609 710921067 934744331 768628669 694940616 …
Output: 166

Example 3:

Input: 204 54128584137 102489125 175293544 90248172 428709575 467374195 439474966 252322724 776814611 291964261 30144011 681295781 606843407 988462079 514300005 16678708 756392128 960102021 220118508 543007448 83445536 838218955 616907759 940632908 914118546 668497076 885049742 825043600 368393907 211929387 580203028 583452067 918011327 12048459 776500932 722742371 638140531 953776347 920911274 24354834 284437245 378182854 285133203 51771749 735416553 618517633 367209863 594494267 425776935 371314862 611859093 842566987 681050289 55389002 887188366 879508552 686838220 24437190 111331025 88385823 512008803 339552870 232250355 578997089 217148114 912953882 142293454 555230333 660494634 640086341 250286820 107364167 20824884 384045838 717398897 461569903 317942246 191787021 428357750 393309278 13193…
Output: 112

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Tightest Stretch of Beeswick - MEDIUM Coding Problem | CodeTikki