CT49738

The Needlepoint Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Weaver runs the depot at the pine barrens of Needlepoint. Today the books show a list of ribbons, and the numbers must be worked out before sundown. 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 <= 3263; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 2279 596948 567 917 431 974 661 277 340 157 95 13 728 39 291 775 372 683 952 893 80 52 718 688 225 529 378 720 436 140 979 86 968 37 177 721 949 144 474 184 593 582 980 347 400 404 917 6 94 389 784 814 854 18 594 776 425 574 343 517 5 177 656 838 862 253 122 10 106 263 643 510 627 703 568 857 497 401 739 725 297 22 424 98 66 224 951 463 579 151 611 309 525 716 176 103 882 425 988 595 759 639 418 173 691 572 37 552 497 529 507 267 118 153 140 508 437 488 674 235 246 335 47 462 900 517 975 834 433 48 82 488 237 305 708 754 85 157 554 710 851 909 303 555 969 31 413 373 233 168 320 944 45 445 330 250 27 225 790 510 621 790 911 920 386 100 30 540 463 221 677 227 290 622 751 855 292 548 401 683 678 106 888 279 798 397 304 541 134 351 630 70 467 64 452 32 118 773 21 401 759 373 305 131 197 655 51…
Output: 1192

Example 2:

Input: 2385 40383 676 952 479 635 654 518 726 632 184 180 79 864 613 232 892 682 895 900 895 860 831 844 103 37 805 125 294 787 328 626 834 888 598 159 795 585 367 586 721 820 611 278 704 712 728 18 348 467 836 676 970 721 609 302 271 747 726 228 291 370 727 325 765 589 801 562 857 361 735 372 532 626 879 80 47 116 900 849 866 443 477 536 497 647 151 784 126 73 179 651 708 19 436 966 789 83 771 74 109 891 859 65 414 48 696 556 74 814 477 212 745 283 914 361 387 477 895 602 578 100 250 826 756 803 732 634 231 895 882 213 383 37 808 303 589 257 584 788 759 415 605 347 913 969 743 692 893 55 993 52 79 880 118 306 719 60 360 294 96 282 238 68 925 998 566 376 770 341 589 340 999 957 775 18 681 664 887 538 962 860 94 84 667 678 440 71 939 718 98 62 627 112 208 539 188 680 260 288 969 374 428 917 603 27…
Output: 67

Example 3:

Input: 73 17814 83 846 986 287 109 633 3 547 161 771 653 754 704 370 795 507 845 311 943 169 183 431 953 323 101 182 255 618 794 591 513 94 955 530 93 68 383 462 645 87 589 970 918 39 890 842 251 228 275 923 258 679 685 907 947 516 864 8 353 752 203 919 398 826 693 885 49 206 975 315 174 251 465
Output: 32

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Needlepoint Tightest Stretch - MEDIUM Coding Problem | CodeTikki