CT53966

The Tightest Stretch of Whitewick

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The log keeper Mina has been asked to win the guild's seasonal contest. On the desk lies a long table of ribbons readings. 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 <= 3002; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 2715 649642 942 713 744 480 744 703 116 589 148 232 13 525 908 889 109 374 52 419 436 325 837 697 875 668 876 309 162 72 998 795 141 25 663 963 806 771 277 6 384 192 593 859 225 951 561 614 723 32 586 874 394 852 101 114 618 337 297 513 505 542 172 110 211 959 313 363 5 965 511 883 958 159 645 427 721 727 286 451 675 223 299 513 829 133 411 753 184 153 626 890 801 882 96 946 998 372 950 558 408 764 362 680 409 337 642 198 300 340 454 358 162 980 177 970 336 217 457 303 9 982 598 119 819 568 400 378 754 584 466 84 280 520 168 19 679 505 575 442 197 529 343 963 44 722 446 538 457 180 920 278 919 421 57 938 190 386 299 72 625 416 636 738 52 237 534 327 599 628 680 856 149 678 318 209 243 530 740 940 141 699 650 196 178 700 143 476 768 5 647 876 223 58 973 392 835 538 987 220 762 19 716 746 38…
Output: 1290

Example 2:

Input: 2245 291964 486 406 431 348 463 222 184 469 257 201 972 973 86 284 415 385 892 584 487 488 631 809 653 530 838 374 513 411 34 598 598 925 92 993 954 43 188 158 666 285 947 393 558 658 138 749 350 325 166 213 59 150 384 527 362 196 676 343 909 43 24 139 635 559 86 99 335 68 604 702 121 18 179 102 122 685 911 746 515 940 891 395 340 855 510 163 500 532 524 984 941 13 883 800 183 564 811 160 790 884 442 857 311 645 127 148 493 873 105 563 294 326 302 910 190 687 560 491 719 84 732 246 585 876 789 333 109 407 510 295 496 569 799 739 465 762 632 252 799 241 490 134 710 152 539 87 580 334 429 359 800 604 739 120 255 356 624 265 393 981 149 480 870 490 102 471 61 871 322 252 603 642 74 382 310 839 720 571 514 307 384 802 302 1 857 649 267 116 455 804 998 145 381 926 405 759 386 48 806 736 543 584…
Output: 562

Example 3:

Input: 2962 73148 316 636 935 1000 626 292 83 343 793 307 843 284 833 202 55 361 430 98 724 165 159 658 119 91 456 425 905 256 937 32 64 806 207 601 235 628 720 990 69 412 913 889 155 211 569 506 506 820 737 788 86 895 244 493 172 395 299 279 127 274 1000 332 199 694 252 511 51 270 110 832 214 60 725 981 878 377 318 773 104 953 948 664 226 178 687 671 654 880 626 360 176 204 628 137 486 434 799 596 556 719 344 441 590 976 487 296 450 333 955 572 47 226 481 971 24 679 245 195 839 900 565 844 235 659 726 923 706 5 845 29 824 983 62 972 542 825 638 273 974 453 543 267 920 954 436 316 301 776 937 143 360 884 797 884 662 129 861 670 30 61 201 661 554 431 383 634 734 437 879 909 566 436 393 316 955 755 319 581 589 750 395 806 940 746 132 863 812 161 992 811 361 696 177 579 684 478 743 926 416 896 810 2…
Output: 127

Constraints:

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

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