CT37896

Rhea's Sunlit stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the wheat plains of Amberfield, Rhea studies rows of stretches 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 <= 3889; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1532 672730947 92602 923410 452273 360254 197158 804716 745160 188628 348555 4270 807273 740390 292806 468842 871126 673869 340239 747213 864658 609191 633246 520882 390018 134712 617060 343354 560443 545382 582911 463024 185733 624437 912870 469196 575509 198205 137535 983672 417893 268354 202835 684188 513213 576026 142486 611120 490604 194828 333012 726497 953730 316761 619010 260557 159974 17285 158466 206228 677403 248379 235367 482043 708629 73454 822250 824006 246224 552654 106694 492801 81946 458291 459603 724151 724849 25906 7726 491091 78229 691531 502952 866933 902332 709460 56902 408833 331134 76276 707300 570867 532621 23886 887130 225280 788558 662548 869133 464560 661531 276620 454643 478467 219198 515110 561257 592967 423428 822226 670545 422656 954341 565672 862582 707619 …
Output: 1370

Example 2:

Input: 2479 912603636 939996 48981 720434 790197 494369 827606 893800 827460 930721 114813 504205 166150 132384 116674 33189 245088 786697 974655 382792 621577 441452 507970 810497 544110 257300 145939 934714 999216 984451 340795 889698 31544 384805 790022 210753 930201 827222 104730 493245 552193 377713 336634 806038 55001 669053 129430 920211 716724 311407 378680 834373 632310 479414 31249 281690 634928 157243 609122 538400 534022 105022 366511 63592 515467 36648 532912 869415 385449 172512 966163 844943 688508 616210 123006 631760 414504 521741 337144 906381 643393 174442 172900 74743 953534 689498 743618 720386 936193 350744 666089 513189 832210 954342 174432 10001 877100 65645 78790 317153 155423 889971 676880 458270 368272 563563 199903 378359 557578 584518 720599 112142 656227 346925 68472…
Output: 1829

Example 3:

Input: 2009 101793863 113284 341739 42565 931766 22275 47189 143606 617204 543118 245620 356297 979726 571390 177708 266348 587677 404448 426844 121150 274998 895239 446562 752662 361321 928948 215853 486945 488577 57564 476089 307588 854964 676987 407598 672207 868262 330932 719657 785053 442176 216534 645542 291777 563212 649593 136779 594875 544328 965259 991169 560100 609417 638619 281709 402861 121794 336646 390981 771934 735952 607137 618800 373282 193302 232725 687355 326298 336841 658767 978620 153829 832209 108109 842022 912443 956992 314207 584535 692974 422680 805455 434924 137082 10837 650209 915450 812634 617656 161507 920307 670796 62747 371664 232073 861130 79396 466174 930309 69227 294838 650279 536976 145197 784260 195296 121797 932714 942812 230325 831839 861291 144198 230454 14…
Output: 189

Constraints:

1 <= n <= 3889; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Loading...
Test Cases:No test cases
No test cases available.
Rhea's Sunlit stretches - MEDIUM Coding Problem | CodeTikki