CT47454

Silent ribbons Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the steppe camp of Horselord Plains, someone must decode the foreman's shorthand notes. This year the task falls to Yusuf, armed only with the ribbons register. 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 <= 2332; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 1656 375880 312 27 2 347 945 934 165 953 157 171 104 461 771 616 89 924 721 244 783 360 76 954 540 251 543 969 207 581 657 912 252 767 308 298 473 241 813 486 347 621 804 117 332 123 977 134 116 297 718 748 268 396 557 813 448 555 682 761 203 271 155 987 882 506 403 237 272 565 854 396 150 979 138 941 539 879 93 455 569 937 415 338 781 357 777 614 999 937 883 40 519 42 537 195 906 755 211 176 720 329 60 409 266 397 877 825 612 619 602 643 200 817 32 196 294 121 613 695 946 780 334 490 200 436 30 193 978 717 718 442 798 313 324 735 590 172 521 722 537 956 835 328 805 633 649 361 656 520 760 215 855 133 686 580 988 93 84 483 741 425 943 168 672 272 622 755 200 956 615 140 873 183 286 527 365 322 677 985 213 928 687 23 52 983 233 638 426 460 69 317 11 873 761 879 860 383 852 638 961 322 903 1…
Output: 706

Example 2:

Input: 504 50254 82 133 580 514 304 622 218 458 598 66 499 160 239 749 437 505 672 325 906 740 561 1 464 711 252 586 570 848 126 445 931 167 429 616 289 501 961 782 339 191 854 446 502 12 140 984 322 724 1 614 572 846 392 45 298 452 865 740 288 107 186 894 927 531 53 27 805 98 317 596 354 961 50 244 613 762 607 202 870 474 783 195 708 815 449 100 955 102 122 175 513 785 232 219 929 550 903 717 91 378 753 49 320 106 275 671 143 429 653 887 620 269 342 751 672 960 446 935 631 416 144 971 873 386 919 592 799 486 274 946 369 986 927 326 408 767 457 799 841 362 40 492 556 305 623 773 187 397 663 653 74 865 576 800 895 336 179 393 801 293 460 643 11 579 850 942 411 351 715 411 944 778 344 540 431 131 473 539 267 729 357 207 882 700 413 62 767 409 292 544 972 399 96 922 345 271 71 487 848 336 147 422 66…
Output: 89

Example 3:

Input: 1059 521278 811 344 724 328 337 725 912 895 457 305 667 305 389 457 877 103 710 527 458 938 143 494 995 991 578 447 914 816 436 600 100 175 609 615 214 339 662 50 811 597 504 621 637 432 623 512 144 278 354 111 959 651 767 890 619 439 239 812 195 376 981 711 503 387 807 813 151 223 920 972 268 912 319 588 432 622 257 346 101 367 9 346 600 637 224 361 87 464 988 806 626 408 896 434 550 124 752 144 168 252 259 972 913 266 555 490 613 237 550 204 995 956 361 611 663 589 2 253 756 337 140 748 858 970 774 741 317 952 237 782 591 205 442 581 409 515 290 300 173 176 765 133 721 211 281 530 365 852 464 851 843 739 457 815 438 639 252 258 77 385 174 880 684 910 621 890 268 521 531 756 767 618 613 302 136 649 829 441 240 102 531 178 397 386 960 233 282 431 873 842 581 418 254 429 227 8 551 449 341 1…
Output: 1038

Constraints:

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

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