CT37905

Last stretches of Fiora

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the shale slopes of Greystone, someone must price the new merchandise line. This year the task falls to Fiora, 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 <= 1245; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 955 198957235 446553 564376 303006 834503 638834 650169 157127 367104 926809 728633 571570 385348 468540 614374 275495 308982 647625 407163 274038 420989 697888 726159 801381 379856 429405 345216 440202 395867 966524 587519 291369 736943 350717 785606 226713 776074 715078 516223 586055 793167 919125 954599 569564 456691 448681 411389 4815 353121 164131 93210 900945 220676 580649 881142 953714 491266 609697 841807 585705 325939 957830 400289 243797 828666 688735 226890 534152 489885 784347 372531 905974 493590 324126 796952 123756 733798 231600 650057 340713 432665 785412 33680 42722 680618 260251 941007 502922 378862 691930 431025 174077 101923 447064 55980 351481 132251 688323 753497 750503 255802 773167 525865 803295 940934 678792 315263 32040 138114 459578 97087 22607 720654 841450 5886…
Output: 379

Example 2:

Input: 894 164601793 752452 678065 158496 650734 682807 900085 585477 427082 126645 758019 59806 997128 948742 114573 255711 185806 603545 550251 268733 487941 63340 703560 506383 238310 413068 659990 181918 135108 142698 343110 895744 439608 829488 972856 930194 638462 689875 179570 936908 493217 958012 148280 73465 153902 882760 254000 656366 83935 981586 811903 842714 532081 355749 67987 478090 349525 255111 80963 630791 862727 418133 74628 134252 266415 311839 38788 951395 837017 372440 23684 877924 689022 30722 596781 66743 483465 599765 834109 224089 576605 597271 265671 470076 785102 417261 771470 845844 238544 977204 782658 894794 578535 504920 386825 452513 185806 562646 508237 930680 542887 866584 686253 464674 110430 991642 260977 700422 180652 6210 912716 148049 805711 544904 156219 4…
Output: 317

Example 3:

Input: 489 180350105 195584 401534 538678 801165 96973 169946 382609 394650 57090 107142 430600 626948 587858 71110 413703 404706 126292 7030 753823 476908 730154 370055 616511 660009 663269 135996 854922 749134 687493 453961 200625 475394 40783 299488 35288 221778 256244 409036 146358 58731 967180 410444 463984 765225 584381 708989 453744 681653 482027 208820 798249 816001 284725 105837 496230 451410 564468 618835 735335 340795 707450 431855 375599 553565 203228 333580 596251 37088 240507 17191 613752 664853 144807 305737 62064 974073 23584 867563 100530 134420 817898 417342 296801 872556 73285 294307 101088 231265 682891 589034 740582 585163 767000 884696 998687 325321 907873 947010 375098 57903 692462 98691 382025 573356 721359 100571 246459 250615 929622 550852 631520 49671 876300 656131 5211…
Output: 358

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.