CT46241

The Tightest Stretch Beneath Glowtide

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the lantern reef of Glowtide with crates of panels, and Sailor the dispatch writer must account for every last one. 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 <= 2336; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 2190 681924 131 484 874 561 221 96 691 991 13 460 633 469 227 674 309 605 786 171 881 301 711 825 40 33 586 856 256 362 182 577 976 224 963 179 791 827 134 241 622 303 574 12 392 135 693 313 650 120 762 374 463 242 762 686 717 473 14 959 921 830 739 563 152 825 680 732 838 658 123 108 718 903 587 850 683 749 182 674 977 299 187 484 897 485 280 570 205 655 5 198 264 372 427 91 307 984 642 450 222 503 889 766 135 82 663 660 879 522 709 214 955 970 46 891 302 878 455 735 659 383 371 190 953 297 625 978 818 253 368 166 7 692 604 407 558 231 344 986 866 645 562 760 693 611 872 689 331 928 360 296 111 78 994 155 800 48 526 338 747 723 385 765 27 587 300 460 389 593 93 281 176 830 524 518 984 261 429 599 80 43 375 943 982 354 989 116 702 447 262 440 160 402 10 304 588 671 266 382 935 769 309 124 …
Output: 1344

Example 2:

Input: 269 103956 819 644 255 988 794 389 470 681 296 660 995 843 72 735 791 834 514 969 597 531 958 577 941 64 68 836 409 191 829 992 476 125 12 235 151 574 52 928 860 132 816 274 852 231 21 985 885 548 816 713 878 779 571 975 361 856 727 333 916 818 876 636 32 824 23 294 580 808 454 514 855 578 433 213 973 46 944 59 69 738 603 821 751 382 412 622 77 737 304 335 607 785 50 926 766 105 113 829 286 811 482 835 605 431 370 83 24 209 972 496 22 700 337 836 421 844 826 347 934 910 804 215 19 897 881 921 482 546 106 19 174 60 170 32 808 378 110 936 839 577 298 658 43 145 178 25 495 491 253 783 525 282 630 787 827 820 33 244 308 471 422 791 552 720 650 98 713 578 519 274 452 290 175 359 591 181 94 511 297 125 931 590 362 166 214 932 207 9 552 268 355 19 860 616 323 977 373 320 299 14 469 218 881 342 32…
Output: 207

Example 3:

Input: 131 45880 588 243 64 472 915 578 214 421 160 294 583 261 367 687 301 388 774 699 159 576 367 394 195 96 768 519 136 90 84 939 765 649 105 54 86 160 190 284 940 533 244 9 41 998 648 468 619 435 399 893 75 864 14 339 888 723 696 270 98 508 736 738 714 89 181 124 501 799 832 60 994 876 919 744 85 615 632 210 862 466 996 188 40 59 578 46 229 39 675 666 268 844 693 195 73 48 781 108 269 101 258 67 293 37 842 659 301 157 506 31 790 444 901 468 254 966 641 281 893 374 698 824 171 368 660 523 372 892 493 202 60
Output: 100

Constraints:

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

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