CT38531

Botanist's Beryl Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the crane marshes of Stillwater, Botanist records each scrolls in a worn leather ledger. The guild wants answers, not guesses. 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 <= 2239; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 1801 60529 762 449 49 434 123 679 689 557 460 76 94 460 923 663 819 465 728 127 534 214 970 287 904 538 93 669 597 592 267 890 648 384 196 520 120 976 565 921 907 710 429 202 957 376 858 278 914 956 647 932 758 100 719 879 917 915 67 250 956 710 100 86 275 993 760 473 63 188 638 970 275 484 682 193 692 37 371 30 867 168 390 301 259 323 514 939 94 628 763 855 842 972 381 467 514 936 412 936 186 388 371 905 612 158 137 826 937 538 484 714 303 339 477 230 629 872 462 762 985 355 824 351 619 658 488 809 531 830 76 324 620 22 956 577 164 229 844 918 556 30 893 747 89 262 471 123 291 856 720 766 500 521 260 153 519 986 809 208 288 35 119 415 344 444 896 648 661 83 360 945 179 624 922 301 721 669 938 634 289 576 44 170 140 775 143 684 384 913 218 163 212 182 923 14 776 163 310 325 10 755 216 890 …
Output: 109

Example 2:

Input: 1308 574235 198 670 11 328 663 179 653 695 213 697 889 459 686 550 130 236 222 162 787 533 408 493 882 827 430 962 379 910 82 896 919 168 741 186 651 114 508 505 336 626 717 697 868 103 93 799 300 95 414 642 63 349 230 308 421 790 792 580 344 379 928 50 779 188 920 624 697 751 426 757 610 523 114 176 615 618 207 133 459 586 523 537 402 608 722 842 139 181 889 407 53 796 360 279 719 956 852 881 131 162 673 138 385 854 872 954 111 461 305 71 747 595 82 131 996 932 424 553 418 209 828 291 813 534 679 978 959 19 868 959 522 914 978 402 438 512 283 144 201 602 637 247 402 936 292 137 898 210 329 175 343 667 605 277 566 761 18 207 857 945 446 169 205 441 530 739 619 334 537 290 970 823 789 54 394 244 863 503 645 976 916 825 436 299 18 80 377 366 344 437 27 671 613 287 722 34 815 623 510 893 914 …
Output: 1124

Example 3:

Input: 1591 309818 36 310 115 418 196 324 764 887 329 290 905 431 660 981 979 714 844 405 643 542 518 382 18 823 5 700 637 83 526 142 833 742 524 68 42 132 75 166 417 55 913 230 464 911 233 816 89 507 275 176 69 29 723 17 799 987 329 673 601 421 415 589 128 534 924 482 668 495 559 535 321 824 390 826 241 820 673 154 2 18 63 831 608 138 492 312 775 759 51 706 218 700 914 812 233 944 115 726 19 508 688 303 499 93 422 186 641 969 430 180 761 559 251 518 300 953 767 11 865 643 791 38 675 68 506 814 877 437 790 660 176 232 345 295 428 878 504 757 785 647 143 580 386 43 222 769 324 835 239 851 378 74 760 108 295 522 304 662 555 838 552 962 686 895 565 463 577 2 647 5 582 80 436 586 791 80 66 449 235 214 41 576 841 177 160 992 690 256 763 998 540 563 190 62 744 838 511 658 72 356 786 800 254 484 730 396…
Output: 605

Constraints:

1 <= n <= 2239; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Loading...
Test Cases:No test cases
No test cases available.
Botanist's Beryl Ledger - MEDIUM Coding Problem | CodeTikki