CT35941

The stretches at Mirrormere

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the lakeside town of Mirrormere, someone must file the annual report. This year the task falls to Amara, armed only with the stretches register. 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 <= 3102; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 1473 132555800567 345860701 405498564 359958027 961933862 982480730 350796074 79757684 18800657 788100855 457296794 581437565 830872627 136935081 196927278 649554934 905139335 568403187 574937921 588157849 390697498 687292898 117567964 116638576 181098551 120439634 487342145 978422194 636911912 294068101 166766401 823644956 999355734 320759407 997921802 993520904 690416911 892320519 766200922 37637606 369633595 876291330 414219649 284721165 485842157 192534970 795583225 896717809 271557332 522014643 341616929 970808852 830124756 414562308 300894562 554195353 441109634 143515363 798449344 312264746 382241932 25017285 380392911 595828725 108153146 278935699 79439566 11184229 140683785 205608860 807991298 794344252 299861846 438664980 765989890 206943745 628261157 2870403 187085404 266300103 …
Output: 252

Example 2:

Input: 1778 165857285111 826678242 749136189 87655822 927849618 307900010 94380260 787219567 320742636 147189649 196821050 567795129 53022348 851156697 476972678 803535974 118537996 492232333 761070611 957577384 90548255 212757880 32587555 774986278 435432895 780915880 869452724 335541393 529623772 704068013 63170466 153680825 842927759 131218054 954717002 267353714 471017055 85611333 413301383 101616124 564719509 917844099 9852085 668870135 416120169 956574808 481074054 647159391 113794098 586378892 38198185 585749679 950789524 107012907 78884391 790579688 644654822 593594471 807039698 961682205 360318450 740330470 31170052 44125679 354420849 995497318 418338288 372093086 864583554 295019107 603416530 818431125 275043497 864711115 263553866 119635442 717588492 347729518 779290561 30623736 444316…
Output: 308

Example 3:

Input: 1889 49269248190 515105320 984611748 197930625 315962623 456333585 113341600 57352562 663649385 738772698 494536383 109235672 355285218 474734070 529532124 394065957 358378527 235556161 849409435 357313570 203414896 586082919 837573273 241091891 536874048 575900480 70204359 90916820 505655322 116873145 363179953 102812156 181768549 692670699 832569891 34071609 546144236 834126576 114237556 177942771 128910677 121556243 846096961 784220394 752964095 945005776 961014885 970513786 894225812 744719084 564940577 173742530 635099348 768161765 235340688 949170903 525889983 23093534 259392315 385917546 900601937 124259092 822493631 325362773 292705966 467958321 923381182 838598598 532379820 160569477 646026054 345219375 621067239 236251256 305388342 964262022 702970244 974041893 389174348 53784619…
Output: 84

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The stretches at Mirrormere - MEDIUM Coding Problem | CodeTikki