CT46991

Rhea Counts the segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the ribbon falls of Cascade Vale close for winter, Rhea must finish the segments ledger - one figure at a time. 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 <= 3779; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 2644 616785542102 55659015 329968811 869087254 186637803 839213860 187058285 186049242 965408648 251843095 134496617 651740629 400270531 517718943 176498985 499016021 558710834 388215701 722665607 199805484 772404924 551976005 402171687 686010461 659628389 795732726 738526963 432554803 833018531 747692830 707212422 240834659 773908448 619596388 696640238 774739524 476492489 565745489 888818899 59870216 869187722 258259552 197194736 841662765 802533397 505948826 601794124 563834770 829227294 946863596 507960162 302893098 653053349 314163020 541542203 556280992 983305386 274304229 871762961 892007688 454039354 88162691 114110248 284064134 464111688 53542639 741054876 726917690 550256842 499320321 201086256 584472245 465489272 691206464 692212895 918098734 740148590 58733870 913633179 8940087…
Output: 1217

Example 2:

Input: 505 86164193573 132189009 875221126 263842843 389383948 774353646 538970763 745193863 245001620 115499078 882505053 164615433 370177742 891050084 673374643 738884515 532661220 903337277 395262135 478295156 442051406 482077210 288146582 358497448 639762378 789176126 335437634 354788177 229545476 491309389 41494839 694033562 588232627 494371036 910065104 340607823 136884236 304542047 574630412 622668921 307823810 201349782 812018647 102796525 706213433 30235292 260205797 510441248 883231411 443797610 634857692 933759027 384646757 834459930 992431362 578177239 276824451 359559662 670927037 802534768 496092350 725514833 325772287 926773852 657157766 370902001 811902486 737793732 543372331 612175761 578491058 205546113 848117686 517173502 211087612 116949862 586358719 941409799 522952171 694863…
Output: 165

Example 3:

Input: 2531 1108173833608 614104807 768481469 556807672 443381591 412435453 207737835 830089526 740117945 120476300 496968822 33026474 280639651 47849271 852691769 340838046 545163074 879066679 79904695 14644645 166120543 804786421 605113845 429176334 851724864 419001464 843429520 334419574 636170645 887758066 168074768 984004272 708889160 690871585 888503843 371746625 95079993 543553201 794399376 260458155 362716536 256496420 714256296 148781215 163096233 586563745 165705770 199647864 832959698 565955734 671475308 914303290 575317709 387895407 211092886 542108335 798350812 939686378 171208624 604671706 672274372 775162011 347200968 915334239 230028607 656515982 233478813 641948789 134246898 134323941 468664556 156669715 724901302 899941990 165413574 550782935 927500760 254366944 347661682 135512…
Output: 2244

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Rhea Counts the segments - MEDIUM Coding Problem | CodeTikki