CT51789

The Woven scrolls of Uma

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Uma found an old ledger of scrolls in the lighthouse attic at the steppe camp of Horselord Plains. The margin notes pose a precise question. 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 <= 2104; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 1184 448114 154 224 585 267 332 792 479 616 735 863 202 696 390 126 551 846 957 320 932 6 911 950 938 377 742 279 969 423 762 960 480 771 68 624 940 802 954 657 576 906 877 145 921 419 820 680 653 830 223 866 782 820 69 116 42 926 501 212 117 401 282 150 822 303 214 741 353 785 456 227 410 542 875 419 501 217 887 135 944 168 242 271 186 41 264 409 805 42 25 932 548 763 731 335 482 337 90 408 74 887 578 13 420 627 490 737 683 44 949 80 253 128 477 799 442 244 511 739 791 661 184 872 43 849 613 886 219 379 353 669 758 753 230 34 562 917 8 633 679 917 126 760 49 239 73 190 275 793 691 421 999 180 441 467 120 967 881 51 264 825 702 297 831 131 752 872 629 925 835 58 243 68 416 749 808 224 298 663 455 644 8 62 467 777 462 645 750 50 418 438 638 848 179 900 518 620 256 652 485 422 790 277 976 75…
Output: 862

Example 2:

Input: 244 114051 29 453 506 625 936 250 496 49 620 55 41 225 262 6 101 318 542 26 745 434 535 962 727 940 383 655 376 605 875 946 516 864 568 671 895 373 900 201 958 71 859 586 983 342 522 653 424 771 48 603 525 786 730 908 251 798 875 458 470 732 871 682 886 543 897 813 82 842 508 105 40 546 382 833 114 507 880 809 626 359 485 517 414 674 343 746 139 436 281 847 901 20 327 59 321 552 923 985 22 547 906 653 856 910 472 937 271 81 24 575 268 778 179 904 258 630 693 931 990 26 25 478 187 685 880 976 901 488 428 318 219 405 142 49 840 85 44 342 463 753 380 259 187 102 60 574 570 248 4 131 361 3 406 379 483 930 928 81 871 878 243 982 708 681 284 517 504 567 354 678 408 559 554 658 338 878 364 825 943 998 342 355 719 788 846 968 571 635 911 78 825 105 720 477 77 376 945 635 212 838 750 482 856 193 34…
Output: 213

Example 3:

Input: 315 107390 476 177 264 918 160 601 239 776 664 964 150 545 523 634 751 997 626 80 102 731 256 923 132 168 296 685 186 989 648 692 410 990 425 60 896 939 634 743 389 651 816 302 828 286 744 421 147 925 761 881 671 386 908 145 786 833 430 219 621 182 358 726 197 186 891 856 328 370 371 169 30 357 807 769 613 865 107 197 499 533 288 728 917 395 875 601 403 301 239 597 435 300 879 633 559 313 420 769 834 909 158 341 451 170 969 239 506 191 338 217 346 734 478 730 369 636 18 323 687 15 288 881 815 615 763 184 449 670 788 968 761 891 907 910 195 809 545 621 20 765 698 168 858 708 296 303 935 727 916 385 581 848 671 794 782 877 85 333 697 820 489 58 762 636 51 194 586 581 450 525 774 586 295 231 530 604 773 530 863 126 403 203 820 847 666 539 772 16 501 991 460 945 153 888 566 478 390 415 230 40 …
Output: 200

Constraints:

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

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