CT42565

The Tightest Stretch at Glowfen

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Uma runs the cellar at the lantern district of Glowfen. 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 <= 1559; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 1227 451066062154 212578109 706406625 484516250 197644690 811608640 649476175 601764918 14151623 46505245 670809187 368094286 205348802 981359566 516734522 800817561 412943675 133246739 498608551 996787883 415067986 96319730 115686512 204247618 368682003 634755601 136798262 420029532 157397260 745433472 690129135 725357664 819991276 63604529 978987595 544181407 923163180 226823536 298732362 661541267 767807381 842014235 393190303 722850688 314044705 159168155 628018318 875057689 900007857 877793613 937406198 301562053 3286397 303989748 529276217 215357860 99051654 477909670 921449682 908631405 271662137 420848398 185216459 942857368 492068680 346836163 996528279 215918536 287408039 693368418 79067099 837414623 176398496 352968853 339690495 94602767 165306651 607145404 450020431 57018334 80…
Output: 914

Example 2:

Input: 1246 575879891608 300971349 413614452 770754761 366458512 447000843 753432193 294271982 166482624 46055879 321142864 591746000 619041650 767950811 507715805 132652888 932128096 260050289 905379028 590753850 98588195 478117240 173540462 678333194 263202774 636805888 714963492 200655889 910341743 497190729 420716552 437234313 291026474 196025689 503620375 656388512 302485377 307738980 165697001 173082259 291938300 705185390 738550945 784197958 587015509 992942041 405322892 33909747 965328736 225742502 208391263 31031032 948784431 716578075 418197614 813570101 355642186 214116028 185565830 497211929 198808317 847404542 214093495 675766532 688370788 82692029 644470073 769045060 58674628 654837876 940559670 790107099 16717483 388170133 116373736 389406973 731576526 343744854 513965336 132973953…
Output: 1160

Example 3:

Input: 1286 501930341382 994527085 589961050 512982584 510948298 410382408 27758952 531442402 778961082 799903760 973330238 814369221 367183247 950857348 716464946 499825677 347953140 229995328 870400605 428127224 403592300 184778759 23967155 84881061 601776454 350154729 248593386 34953003 221262792 360797088 723936228 787643289 46321906 465947645 730353405 309791217 465723318 54278761 263152005 281323706 5894860 796534546 313614607 736708206 85703819 39184582 673853551 511192528 783570499 57286976 458896649 687830220 862734854 351696685 3253349 272242673 542009877 347846210 118724244 392591171 950274970 463700334 692112664 925181435 644786894 973893322 249599333 303327925 702392450 452741552 652290398 356257043 907373058 468115656 677312120 40243469 382286131 413430484 875650654 783802298 537021…
Output: 1002

Constraints:

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

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