CT54641

Tailor Counts the scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the ink district of Scriptoria as Tailor unrolls the day's manifest of scrolls. The tally will decide the next shipment. 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 <= 3180; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 513 252294 145 541 788 932 235 239 684 150 613 407 305 641 218 595 758 815 832 826 502 763 289 128 137 230 512 763 268 50 679 195 513 395 800 747 911 140 797 754 175 125 132 249 907 454 995 362 83 782 191 600 372 256 453 605 807 729 861 935 357 866 221 179 423 260 570 995 439 121 13 903 835 858 119 920 393 221 381 458 697 411 484 180 896 659 571 391 697 547 216 1 583 702 473 237 736 507 502 789 448 758 609 582 758 270 900 16 472 689 741 390 701 903 777 764 807 958 171 418 761 572 766 847 134 149 996 978 577 475 84 274 678 111 216 714 828 531 46 479 351 556 676 74 616 582 531 769 98 648 591 495 547 713 54 27 681 279 389 57 903 560 106 240 625 305 890 468 795 21 265 64 420 576 390 451 521 903 73 279 85 450 455 926 895 300 980 939 273 915 342 930 171 796 357 616 967 58 76 422 267 341 938 118 …
Output: 506

Example 2:

Input: 888 134289 398 705 446 541 457 634 802 827 95 722 507 65 323 951 345 216 961 633 498 868 588 836 567 809 308 486 396 93 678 676 112 904 698 520 962 564 853 835 705 55 3 865 813 485 260 581 740 821 242 585 861 532 461 455 213 162 232 879 602 468 529 883 282 437 719 16 610 341 35 64 802 461 509 669 847 147 899 217 510 450 700 291 464 969 659 70 12 730 866 552 162 536 761 300 433 281 709 186 298 752 508 155 513 697 575 304 369 135 501 610 320 618 956 231 319 741 507 945 676 886 937 498 681 50 351 587 536 912 209 794 949 687 652 908 973 117 536 942 302 852 486 183 437 232 635 315 320 798 605 74 438 576 314 851 23 767 620 496 898 591 481 390 74 117 902 808 715 665 578 215 688 964 534 229 759 649 52 633 301 453 930 824 611 802 433 276 430 967 747 731 543 982 199 65 664 158 256 497 158 112 281 38…
Output: 256

Example 3:

Input: 528 180955 395 171 851 716 811 378 673 570 986 640 899 255 725 140 89 747 923 379 336 845 88 587 550 480 181 496 952 199 686 805 989 678 586 704 715 803 72 306 100 181 17 888 885 294 512 999 802 697 350 496 151 688 518 891 90 78 944 958 855 893 350 816 227 424 36 592 909 826 977 690 541 126 232 902 557 294 682 780 158 613 306 455 460 603 23 286 308 994 3 712 737 656 617 521 995 120 964 209 382 288 684 952 849 638 726 935 244 797 108 326 920 210 321 533 714 175 633 259 542 133 94 6 788 468 488 50 239 664 808 404 202 454 809 583 940 246 452 696 148 232 666 32 706 460 452 84 612 922 43 636 279 796 337 755 313 594 309 159 100 87 336 777 590 596 729 51 724 327 166 270 795 354 920 110 252 894 702 985 913 315 373 514 591 178 154 199 561 26 454 161 929 829 863 737 177 928 237 903 373 722 644 32 66…
Output: 360

Constraints:

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

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