CT52764

Aria's Tightest Stretch Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the cliffside roost of Stormrest. Aria spreads the scrolls records across the table and picks up a sharp pencil. 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 <= 1049; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 415 144781 980 588 185 706 657 584 509 803 735 373 214 981 475 257 985 70 925 875 881 356 327 130 25 245 700 470 472 289 286 90 799 281 681 873 917 358 740 597 399 734 252 515 158 749 845 744 328 129 26 207 894 656 522 386 421 651 866 825 12 209 95 460 811 197 54 853 612 929 886 359 216 648 946 695 98 49 717 15 151 996 48 226 522 709 244 268 55 265 188 62 16 305 55 408 965 687 752 995 224 494 791 941 809 325 556 857 511 552 681 814 914 392 676 151 933 661 251 645 741 893 928 361 346 180 171 631 458 875 16 819 491 222 522 229 283 411 189 319 499 679 44 470 493 9 116 363 239 828 657 42 280 853 560 798 87 656 291 676 919 56 884 696 810 119 103 544 228 966 590 505 430 552 311 14 913 195 739 716 899 107 508 384 447 978 563 504 344 357 663 136 775 714 142 431 762 478 103 193 474 801 543 393 881 …
Output: 280

Example 2:

Input: 761 317423 630 10 341 796 539 293 273 922 315 170 298 146 146 799 326 204 730 827 434 693 891 225 363 684 256 933 966 360 552 137 862 557 123 742 747 22 781 660 485 656 184 308 51 925 576 485 378 511 639 873 331 724 940 287 973 858 140 364 362 588 836 825 219 101 783 195 420 31 959 66 407 143 612 884 615 97 810 880 472 186 714 718 396 561 604 216 916 333 155 243 372 71 284 414 106 781 591 866 28 211 43 950 666 520 29 916 450 884 279 621 509 481 992 300 971 657 990 61 168 498 620 557 229 780 129 623 704 1000 651 694 205 164 58 622 852 880 681 814 821 895 417 420 215 196 169 805 60 783 735 184 789 950 231 963 223 659 967 124 128 177 95 150 511 258 754 178 366 922 319 994 272 198 836 658 770 855 138 661 697 978 464 572 886 137 174 320 311 936 86 793 961 628 767 237 783 303 792 977 906 367 272…
Output: 618

Example 3:

Input: 81 24913 156 285 76 816 139 323 388 181 131 896 344 633 970 346 902 93 797 844 487 989 314 686 530 919 557 664 28 962 679 452 779 777 624 720 109 30 897 590 161 571 698 834 91 790 414 593 786 866 942 59 425 955 678 442 398 120 705 49 422 120 868 560 632 361 410 401 632 273 977 246 387 749 885 986 303 234 574 697 939 845 117
Output: 42

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Aria's Tightest Stretch Ledger - MEDIUM Coding Problem | CodeTikki