CT45955

The Tightest Stretch of the Bronze scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the crane marshes of Stillwater, Kian records each scrolls in a worn leather ledger. The guild wants answers, not guesses. 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 <= 1418; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 1175 169230 716 19 877 337 910 579 269 181 496 177 356 837 297 396 89 578 102 718 410 408 84 61 84 976 941 357 623 289 921 81 601 690 435 212 258 121 543 379 269 789 38 59 246 914 557 146 423 583 790 818 741 516 683 137 600 91 108 798 118 999 531 383 929 318 3 959 333 288 526 240 272 184 785 777 254 804 286 567 672 878 749 413 191 382 659 630 879 430 175 795 873 82 334 913 385 296 834 858 622 739 531 671 206 728 782 594 593 8 13 720 623 299 543 905 715 263 190 30 121 300 327 544 413 540 38 918 172 280 803 245 759 308 829 656 752 602 38 934 204 505 848 972 193 236 305 880 913 702 721 43 316 583 707 447 865 130 828 443 691 528 513 994 238 312 499 437 268 415 446 24 674 708 926 863 41 212 892 641 917 528 805 448 364 800 956 579 179 179 509 21 192 646 393 552 473 914 263 378 539 22 477 713 821…
Output: 319

Example 2:

Input: 675 12734 880 368 33 8 186 947 889 54 851 504 746 13 934 687 795 967 412 751 956 497 129 739 387 676 139 191 236 877 766 60 251 368 630 589 170 26 287 62 543 997 35 750 260 207 172 633 986 757 516 361 508 243 739 82 888 345 83 630 410 639 167 34 271 283 192 819 578 961 335 634 391 215 750 740 906 733 649 107 196 12 432 960 904 646 413 245 739 849 368 246 193 832 228 100 324 221 276 204 56 648 850 826 471 302 694 460 948 34 365 704 486 851 480 305 845 286 885 739 980 178 569 348 842 33 865 942 46 221 211 133 514 95 993 997 410 917 265 827 794 935 208 754 130 497 754 96 341 20 531 344 562 405 500 15 739 702 354 611 379 848 216 539 777 229 592 89 840 801 417 123 244 149 501 954 945 679 550 880 956 149 493 230 860 642 750 456 601 361 241 227 253 684 804 850 503 874 980 370 354 39 993 442 381 3…
Output: 20

Example 3:

Input: 82 30205 107 57 864 132 86 782 584 955 400 838 817 482 162 827 336 852 572 734 887 791 799 829 225 469 905 468 565 342 299 963 987 321 680 326 845 771 964 385 263 507 175 477 821 555 867 541 98 181 444 179 179 823 823 901 611 780 296 311 708 713 339 163 465 619 382 193 355 805 23 559 429 841 757 775 416 342 748 465 378 582 36 987
Output: 51

Constraints:

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

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