CT45660

The Roving Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the steppe camp of Horselord Plains with crates of panels, and Dino the quartermaster 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 <= 2593; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 840 142806 555 999 842 595 533 38 857 217 966 383 674 470 980 61 508 501 125 219 673 446 954 989 364 945 982 782 412 343 301 724 424 490 762 834 558 109 91 872 6 247 532 111 364 992 113 48 896 728 261 986 92 46 59 167 152 248 251 896 358 925 619 124 434 348 652 380 544 393 20 578 983 522 896 831 907 438 319 837 545 736 336 942 86 683 391 612 668 435 736 761 572 686 89 867 827 732 179 279 606 195 951 867 31 508 476 618 336 478 213 321 479 344 80 760 273 355 241 157 826 545 209 172 103 753 717 312 141 260 606 140 153 382 895 383 7 460 688 861 847 990 570 366 727 54 714 111 131 436 926 44 623 767 674 835 367 704 798 573 256 981 244 588 93 293 708 710 166 970 796 394 866 131 370 477 992 726 314 479 612 226 973 189 845 489 609 25 963 706 45 317 634 792 960 989 365 260 13 317 408 710 237 530 994…
Output: 276

Example 2:

Input: 2027 247466 703 878 269 516 557 953 403 677 765 88 467 837 841 639 896 230 634 13 697 430 538 442 794 551 886 434 271 166 603 588 134 569 840 713 134 746 427 310 280 291 914 602 123 415 77 290 915 341 180 389 717 467 599 969 859 732 126 314 644 286 863 213 179 377 496 165 253 463 80 315 758 316 615 933 218 171 636 919 815 80 444 474 157 766 351 444 326 340 349 219 756 622 745 724 826 690 163 776 259 747 252 684 56 614 969 376 793 416 484 663 304 645 411 305 379 888 839 467 987 168 522 722 306 319 657 109 485 205 602 227 468 268 187 585 294 475 745 629 492 843 829 586 411 655 127 740 629 819 178 261 31 708 813 364 256 382 857 729 392 836 443 115 561 822 349 317 443 938 477 714 411 964 90 80 959 194 837 399 215 338 323 626 562 526 966 99 102 77 416 372 806 120 38 33 816 655 85 650 916 131 13…
Output: 475

Example 3:

Input: 2408 454892 411 70 215 449 97 552 39 993 437 12 506 852 401 999 12 192 665 44 948 805 681 7 307 886 321 280 107 427 879 491 895 335 166 154 603 361 560 419 60 552 9 348 753 350 526 76 833 225 780 70 377 224 984 501 39 701 872 932 105 470 396 628 768 478 85 758 265 203 395 774 309 287 368 983 917 550 902 489 893 56 792 669 324 194 401 1000 192 226 983 243 99 129 89 671 810 730 3 670 851 44 889 301 332 713 984 61 95 714 894 125 20 853 952 856 669 364 899 598 897 671 221 317 237 874 570 729 711 763 704 339 586 873 907 156 316 322 602 668 2 840 304 716 169 263 709 84 962 326 466 503 850 934 288 582 93 406 250 108 200 233 545 788 953 172 639 457 874 348 315 11 645 717 211 311 40 321 381 337 999 299 647 994 161 164 442 988 263 150 977 612 402 496 888 990 343 153 406 856 377 720 490 513 639 929 7…
Output: 895

Constraints:

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

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