CT53782

The Tightest Stretch of the Azure panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the indigo vats of Bluehollow, Parth studies rows of panels entries. One clean number will settle the guild's oldest argument. 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 <= 2028; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 460 233924 437 666 874 247 312 332 86 264 842 92 133 304 814 601 358 732 17 597 35 942 84 790 164 747 522 57 112 592 773 799 440 851 844 384 811 440 979 851 642 81 695 10 515 360 31 274 872 785 831 878 771 551 404 457 790 181 896 670 251 216 237 268 101 793 278 1000 579 723 910 120 460 917 818 180 848 613 802 113 305 883 889 54 600 706 403 25 719 108 670 961 965 5 42 684 494 151 375 348 936 831 843 490 43 785 340 589 946 269 606 458 219 292 507 855 591 556 143 948 982 754 71 125 449 662 563 839 706 474 559 565 610 926 596 405 534 91 322 276 605 488 892 158 285 688 185 668 899 502 260 642 923 756 846 610 485 268 941 89 511 716 46 740 940 727 208 913 810 752 795 987 334 695 252 714 167 803 515 388 12 889 987 666 315 989 683 705 549 123 481 821 315 455 362 648 414 510 791 118 94 608 940 768 7…
Output: 445

Example 2:

Input: 1703 106428 472 713 868 724 152 250 858 99 528 427 121 92 182 416 110 803 274 899 948 987 36 921 639 413 36 440 814 520 517 318 114 287 89 984 324 415 42 588 798 595 243 374 979 246 341 640 711 130 115 263 562 989 655 731 563 761 766 91 593 911 68 830 544 690 497 979 642 117 327 500 198 646 227 502 721 628 945 712 673 860 362 756 507 457 320 219 46 882 190 341 747 799 654 940 405 822 357 609 746 373 843 956 7 441 4 775 335 588 757 535 496 759 621 235 184 969 223 360 62 766 131 406 226 302 448 300 945 322 641 755 456 969 482 138 936 49 280 802 398 261 173 958 536 490 443 776 964 882 808 222 848 876 722 434 621 482 391 87 14 419 270 983 988 180 679 555 383 138 828 239 469 330 170 421 179 366 631 414 728 265 833 877 665 554 52 532 99 34 401 358 565 706 497 641 893 378 684 890 639 351 263 851 …
Output: 195

Example 3:

Input: 211 14942 617 63 570 694 872 41 443 728 956 141 705 568 593 738 708 541 517 225 72 916 958 765 522 868 399 381 827 502 603 143 11 156 73 7 980 622 514 648 869 969 807 468 363 527 850 484 616 202 227 934 22 649 796 486 956 66 439 746 590 660 385 468 290 764 924 255 157 541 207 718 651 349 733 300 945 795 86 996 845 474 73 92 802 76 625 264 848 881 29 543 869 965 873 975 792 138 262 153 637 716 250 769 761 303 713 855 446 620 845 690 927 789 255 423 712 408 954 538 527 408 947 32 525 996 589 554 379 454 139 926 673 276 643 613 511 892 210 163 298 478 129 245 687 852 383 964 354 779 406 72 101 686 42 842 144 14 354 251 48 76 630 5 604 954 839 419 13 37 381 775 979 932 934 469 601 869 921 516 521 45 55 333 574 756 375 367 574 989 9 262 602 271 208 55 299 247 454 498 804 359 656 784 604 26 885 …
Output: 24

Constraints:

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

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