CT45444

Smith's windows Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Smith runs the salt store at the lily shoals of Padmore. Today the books show a list of windows, and the numbers must be worked out before sundown. 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 <= 3095; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 2729 263119 271 68 617 411 454 123 904 528 609 721 566 91 924 101 729 51 753 94 989 343 137 802 930 205 814 528 993 925 380 251 612 85 497 405 946 496 598 866 91 566 966 102 421 232 930 944 360 253 75 908 826 634 885 568 966 354 143 815 169 352 29 926 19 831 698 452 457 563 497 755 536 84 228 732 703 949 15 715 285 68 687 522 611 147 500 37 143 611 480 277 146 777 681 1000 729 66 869 671 214 463 958 62 270 847 382 199 677 605 580 653 5 845 22 602 571 915 776 614 332 551 142 992 483 591 630 147 76 835 914 259 230 343 585 883 207 401 139 416 826 743 256 732 619 648 290 472 306 758 372 310 738 676 745 156 412 141 335 921 724 345 218 764 667 69 373 790 742 819 112 10 214 52 597 338 706 843 158 367 911 335 667 770 372 776 234 488 180 150 925 188 618 34 67 118 733 817 99 178 681 161 741 377 656 …
Output: 490

Example 2:

Input: 1011 457786 17 425 236 713 62 508 285 132 106 611 815 149 89 443 869 747 606 437 717 400 963 436 357 688 289 259 610 76 798 843 708 584 730 174 153 792 676 367 47 208 760 349 934 176 266 408 223 986 429 969 633 926 527 117 675 806 409 556 633 804 946 460 795 419 985 860 798 706 664 512 601 977 538 721 447 814 369 625 142 649 508 741 250 930 557 497 856 586 802 118 445 914 504 528 266 761 934 173 793 169 529 553 944 177 293 842 121 301 265 165 296 36 78 334 503 17 149 532 27 338 560 178 235 852 228 519 240 971 251 858 637 110 137 138 899 361 388 764 304 681 260 118 611 428 222 505 357 843 507 631 179 328 644 885 970 985 15 943 79 555 122 806 224 387 112 331 325 311 982 409 595 249 214 872 635 459 480 368 52 863 262 704 988 730 581 394 253 822 516 594 707 913 906 485 165 561 245 221 104 760 …
Output: 930

Example 3:

Input: 486 155137 203 691 157 577 673 572 517 58 543 348 427 367 431 551 482 24 52 359 367 624 554 245 556 356 408 411 470 532 938 658 653 659 512 418 240 22 228 968 283 416 425 42 769 827 865 822 607 54 417 998 818 259 957 513 179 651 272 928 648 726 161 1 257 459 56 81 15 814 800 500 425 984 67 776 851 695 790 32 241 245 573 998 620 670 558 268 709 996 24 606 318 369 312 969 932 140 643 930 549 618 334 525 401 951 639 998 174 793 673 627 16 782 965 74 891 279 758 893 275 627 668 953 635 402 3 359 139 54 602 834 635 933 932 369 834 149 536 596 321 372 72 44 722 629 343 561 241 442 437 818 284 330 464 642 312 263 519 616 910 874 822 419 234 835 559 692 879 141 509 620 303 506 88 825 64 70 39 853 367 310 631 205 602 262 352 254 946 323 517 978 856 81 857 900 567 927 721 733 782 604 16 862 597 482 …
Output: 308

Constraints:

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

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