CT54545

Jessa Counts the scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the seal rocks of Barking Cove pays by the answer, and Jessa intends to earn it. First: the full register of scrolls. 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 <= 1966; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 44 10951 964 438 849 42 554 257 35 435 650 498 848 997 562 862 259 488 939 555 611 260 978 720 528 929 134 238 909 173 97 719 331 781 673 62 329 443 274 69 771 795 820 477 161 455
Output: 17

Example 2:

Input: 730 343717 724 100 858 605 481 424 935 192 836 39 896 707 479 805 455 165 33 106 236 322 108 903 774 210 740 739 237 484 931 313 950 851 870 361 651 68 866 484 684 243 76 678 114 445 187 187 124 45 463 312 12 105 799 929 777 832 237 904 466 725 294 167 219 668 90 639 344 661 72 513 771 707 904 601 763 230 639 41 196 69 950 285 136 113 907 411 151 25 586 255 291 42 319 596 55 974 730 930 135 867 814 496 769 563 243 920 185 248 21 282 174 266 769 233 803 199 50 68 771 571 637 135 883 206 268 281 490 172 767 684 144 792 475 188 994 109 963 450 806 784 123 311 377 6 533 953 21 319 519 903 970 616 126 882 101 837 439 285 588 665 826 455 220 831 395 156 909 732 980 345 188 339 933 4 82 558 730 535 116 854 210 201 12 384 647 738 509 180 895 238 547 498 259 980 350 985 507 116 567 689 295 963 332 …
Output: 667

Example 3:

Input: 1752 169472 920 809 368 597 890 123 140 846 925 352 903 69 969 409 686 73 364 640 319 579 119 958 774 746 341 541 25 478 805 46 862 95 905 303 714 723 594 253 895 300 82 696 751 158 545 666 429 145 731 240 683 385 736 753 259 129 249 646 750 73 251 412 252 879 797 606 337 359 570 993 679 320 372 946 644 358 171 645 964 722 321 521 62 214 389 549 709 641 971 128 665 764 174 666 664 240 450 890 966 247 379 977 828 671 938 479 712 866 249 348 134 222 435 338 818 633 259 672 330 149 580 917 120 72 521 27 722 995 550 124 703 31 642 33 882 836 451 660 540 309 458 104 915 516 735 224 972 601 734 293 943 938 341 638 183 548 597 112 975 396 854 162 974 166 417 568 312 164 468 92 324 64 703 604 757 107 745 286 11 250 193 447 609 98 679 150 222 708 608 227 638 408 726 849 129 618 108 72 434 323 909 1…
Output: 323

Constraints:

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

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