CT46611

The stretches at Tuskmore

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the boar woods of Tuskmore, someone must file the annual report. This year the task falls to Rune, armed only with the stretches 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 <= 1247; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 554 39786 280 449 313 19 604 495 287 533 805 634 465 510 556 389 847 120 402 457 783 163 360 844 476 293 321 687 469 262 499 725 275 393 55 965 129 951 176 121 352 697 832 529 907 150 868 452 145 976 818 583 152 736 428 28 277 586 651 68 447 156 508 354 40 712 584 171 798 869 895 90 692 456 969 753 677 443 422 894 864 449 55 882 794 507 789 13 379 663 652 997 663 342 95 41 321 593 525 844 567 570 818 779 639 367 430 641 39 364 243 804 570 888 108 940 263 782 29 7 503 620 198 981 552 384 400 16 533 970 395 452 830 869 707 345 762 417 253 151 873 310 468 499 282 102 791 956 221 521 386 338 535 985 219 774 6 931 606 502 422 394 746 929 472 106 395 382 434 9 814 509 124 395 639 687 472 667 972 9 120 763 691 182 616 625 463 99 659 265 672 614 119 961 765 640 250 242 390 338 230 114 996 961 647 …
Output: 72

Example 2:

Input: 619 31958 290 323 683 115 581 939 894 502 250 98 65 955 210 317 638 405 794 187 56 599 224 1000 441 573 961 196 572 726 316 774 11 163 984 103 889 4 802 513 152 860 535 250 923 607 183 342 715 421 929 917 134 159 928 153 885 315 921 389 593 819 631 930 990 373 842 281 163 239 381 299 381 700 432 403 300 554 761 801 570 147 415 992 958 368 468 450 242 113 169 283 991 828 555 787 194 698 370 740 112 173 934 418 889 833 148 279 529 28 570 559 838 341 720 869 694 942 295 213 744 617 912 2 243 171 919 96 406 892 654 611 933 680 564 464 402 28 149 375 997 636 343 3 766 444 932 181 34 433 910 321 508 89 319 251 26 760 281 862 611 511 264 35 558 442 467 210 994 288 789 475 589 90 424 351 798 119 102 276 915 737 108 500 550 423 100 55 881 229 310 863 534 235 961 997 741 299 72 46 836 281 2 340 521 …
Output: 55

Example 3:

Input: 781 303838 743 261 691 982 199 310 827 302 937 649 649 566 306 395 255 453 441 216 726 99 534 610 118 322 668 927 135 86 25 259 884 436 422 770 441 87 949 815 204 624 856 777 327 609 637 602 468 937 146 252 124 606 753 516 45 919 949 230 449 91 981 757 479 691 854 804 928 410 635 297 184 61 802 238 13 136 722 412 263 635 988 876 639 71 502 465 224 988 988 858 35 430 738 42 113 80 271 746 9 854 511 369 975 603 189 789 81 164 147 401 272 281 681 960 184 404 429 138 870 63 328 575 793 290 110 299 749 285 604 410 862 873 450 600 104 955 344 227 586 615 60 1000 186 228 314 545 183 393 64 398 932 408 966 905 124 930 783 398 736 472 234 458 417 859 268 436 665 458 700 961 819 293 530 616 463 596 231 222 649 543 376 758 42 991 60 199 212 155 468 706 620 999 255 438 718 578 563 698 964 277 353 189 …
Output: 623

Constraints:

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

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