CT57117

The Tightest Stretch at Tranquil Basin

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the lotus ponds of Tranquil Basin close for winter, Nandini must finish the ribbons ledger - one figure at a time. 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 <= 2389; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 879 96715 550 368 922 935 986 589 275 192 476 911 281 206 841 99 598 953 514 727 427 235 305 298 956 201 987 638 295 741 496 517 527 854 728 730 31 407 529 952 928 885 634 369 592 279 136 250 512 466 600 973 82 556 224 667 663 492 277 296 55 297 401 361 170 709 962 936 72 462 701 821 538 718 998 133 236 429 645 375 544 675 850 70 791 57 559 406 943 417 71 531 366 874 624 95 324 893 718 58 839 966 507 734 855 433 493 367 832 25 405 692 293 951 833 731 158 719 413 931 805 185 688 3 34 228 830 554 288 92 992 326 885 791 554 530 285 70 238 134 322 342 832 796 396 586 986 449 171 839 391 966 402 110 820 81 819 475 641 524 29 595 530 1000 360 998 731 641 473 790 407 11 99 233 683 518 109 424 514 879 836 668 526 942 166 883 551 716 992 541 723 788 94 740 721 701 710 958 240 961 803 929 733 38 977…
Output: 171

Example 2:

Input: 471 31054 127 484 887 955 521 767 98 147 304 637 805 587 40 336 835 328 186 828 58 982 370 777 898 76 592 19 225 92 955 966 518 618 838 714 633 258 553 650 187 685 773 329 789 160 228 303 612 971 778 971 303 264 925 465 293 732 591 411 64 410 454 863 134 726 719 350 569 867 972 200 332 143 904 916 358 320 518 753 667 79 901 643 293 978 673 342 171 323 1 404 771 135 48 790 137 732 154 136 370 762 771 560 557 22 654 434 248 924 334 542 778 145 332 270 69 681 534 319 992 804 657 767 876 784 916 398 418 554 761 571 314 619 553 726 284 580 639 947 420 712 686 426 503 105 720 686 510 469 714 256 791 909 389 932 697 995 901 607 124 360 532 211 564 915 834 225 72 481 718 538 200 965 404 4 304 97 459 981 965 249 582 292 801 981 720 330 606 524 931 386 954 998 364 715 963 803 266 462 830 784 855 357…
Output: 52

Example 3:

Input: 1077 149560 426 605 708 175 332 34 123 350 110 841 315 625 957 842 136 594 192 850 706 766 679 369 351 723 600 259 804 910 901 90 723 514 111 76 702 697 356 248 543 454 331 683 770 498 814 933 914 514 863 498 528 311 978 818 453 950 958 689 409 429 623 443 718 852 688 335 4 768 339 165 367 880 352 385 575 254 289 467 306 701 713 723 423 735 379 674 909 291 169 648 500 612 25 865 787 75 500 6 413 743 440 508 295 900 528 49 244 526 679 769 46 498 397 779 555 134 320 450 105 81 578 15 160 57 347 691 797 661 986 882 932 406 95 927 944 238 455 772 182 280 49 778 847 770 207 622 62 548 674 194 526 759 538 321 821 324 444 545 18 395 863 285 275 199 204 974 740 542 926 228 939 297 484 774 722 466 408 890 259 101 834 172 97 404 883 166 651 628 653 797 833 582 628 455 85 647 152 108 760 699 330 13 3…
Output: 283

Constraints:

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

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