CT53752

Keeper's ribbons Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the northern keep of Frostgate; Keeper weighs the day's ribbons manifests and starts the calculations. 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 <= 3924; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 2162 491678 555 681 178 821 116 1 76 88 390 543 715 79 843 860 877 264 199 239 278 817 222 400 467 19 55 453 52 740 185 700 9 925 142 889 567 987 894 64 980 264 900 80 87 515 203 910 257 949 982 548 514 893 858 184 193 74 88 727 795 459 876 210 111 914 104 862 652 714 607 638 285 374 791 335 587 39 495 140 845 992 428 16 59 106 598 492 943 627 472 117 579 766 941 899 629 890 408 966 663 849 541 845 602 138 311 642 422 811 874 801 942 273 361 892 652 233 688 355 926 128 765 825 156 462 844 388 352 677 202 992 438 504 292 317 888 565 201 67 188 330 197 981 398 323 713 87 841 503 769 111 997 403 135 226 420 276 969 523 860 136 772 186 627 361 215 847 68 554 973 752 427 349 690 15 947 522 424 453 995 65 472 724 6 16 744 850 628 432 90 775 688 672 376 32 355 584 571 966 599 802 882 908 112 291 …
Output: 954

Example 2:

Input: 3432 1423826 551 101 86 632 677 44 669 890 692 316 576 571 638 465 778 800 259 935 472 131 509 753 963 434 103 519 605 496 107 879 177 91 975 556 135 157 785 344 82 336 938 498 250 816 814 950 425 576 120 418 914 13 458 965 667 963 44 235 82 597 322 111 797 683 703 205 258 380 363 563 217 441 926 845 941 328 251 817 778 918 647 834 334 264 182 708 586 555 846 405 729 620 24 636 659 717 865 745 291 357 943 957 550 92 958 395 2 711 173 362 330 864 101 432 712 328 306 142 830 100 856 180 257 838 21 576 642 162 553 215 751 86 124 291 624 878 880 154 92 559 840 96 76 852 832 600 213 468 510 112 945 418 341 192 671 383 462 828 993 676 5 35 66 735 715 866 38 557 915 200 422 237 570 314 453 285 988 664 797 170 466 875 609 778 615 353 99 366 932 962 741 586 537 58 932 256 315 550 647 47 139 624 679…
Output: 2826

Example 3:

Input: 356 9172 524 330 187 156 267 148 370 476 827 542 808 246 89 576 29 426 832 357 614 794 234 396 965 989 347 308 660 219 278 810 269 576 364 159 833 593 3 329 414 929 765 702 338 950 589 764 610 422 246 547 234 645 549 317 70 819 254 962 675 791 282 903 864 600 693 549 292 789 235 844 885 13 353 665 379 550 481 976 91 639 18 173 636 88 64 367 348 119 670 480 33 97 564 79 800 764 530 529 787 760 368 146 796 854 513 553 940 37 163 629 67 520 526 827 869 512 63 179 946 297 855 685 488 170 889 246 173 228 233 981 531 723 885 837 826 648 974 714 529 994 424 777 548 29 72 72 686 206 588 437 290 126 703 951 680 263 343 928 704 448 725 359 163 672 533 995 64 740 484 151 878 582 927 282 801 121 71 979 409 987 661 765 480 798 149 479 159 336 184 143 937 648 599 224 408 952 916 41 332 867 86 312 513 80…
Output: 13

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Keeper's ribbons Reckoning - MEDIUM Coding Problem | CodeTikki