CT44747

Ravi's Ledger of stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The factor Ravi has been asked to rebuild the damaged itinerary. On the desk lies a long table of stretches readings. 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 <= 3636; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 3583 1415240 224 349 813 463 144 926 523 566 853 778 192 90 271 100 73 522 322 138 221 673 830 568 798 417 476 532 595 105 263 298 920 868 91 811 920 725 634 683 758 240 662 712 329 227 888 866 651 722 124 904 778 569 119 510 925 755 562 454 225 130 709 71 431 165 790 84 741 959 633 573 558 650 989 668 591 593 61 60 866 832 95 614 913 356 389 487 490 52 522 175 22 21 82 17 144 53 944 839 45 307 158 948 938 72 386 951 755 1 139 390 21 273 651 353 136 519 16 953 840 550 114 642 278 929 116 144 670 603 93 743 999 193 458 840 119 175 723 520 499 373 271 316 291 717 98 500 822 691 15 547 733 702 866 768 223 395 480 563 915 120 809 245 30 836 695 148 72 828 303 763 334 839 465 838 331 952 680 55 29 280 944 969 914 82 262 284 875 455 276 749 727 86 81 197 84 837 644 133 111 26 253 481 683 750 192…
Output: 2850

Example 2:

Input: 920 140978 58 485 926 32 136 9 379 866 828 196 732 154 586 727 552 584 438 282 487 99 117 571 712 826 156 574 470 129 574 408 411 451 295 854 447 145 942 443 468 280 943 265 41 942 686 456 95 656 767 318 923 410 430 28 776 575 825 2 750 303 559 145 256 182 184 944 435 639 569 118 224 969 659 309 695 821 714 43 807 346 222 474 384 499 671 80 273 404 89 153 7 732 15 844 547 39 736 333 534 713 384 6 17 383 456 639 16 714 483 500 552 193 386 308 721 323 286 610 958 918 862 469 563 771 3 744 251 757 568 263 990 227 543 417 954 127 351 477 855 743 943 713 599 86 305 656 365 201 322 681 336 900 762 297 88 712 574 949 38 855 579 932 140 553 155 43 268 990 900 390 842 671 755 53 803 3 509 102 241 352 471 111 224 96 455 264 672 741 645 260 376 552 168 208 558 867 877 772 182 18 815 56 904 922 9 752 …
Output: 259

Example 3:

Input: 1653 535173 986 916 161 928 805 278 604 101 520 738 75 602 663 939 683 286 1000 7 51 76 468 283 663 357 980 644 81 512 704 738 902 734 9 45 922 375 686 936 653 125 993 953 809 729 86 353 932 962 717 293 81 143 49 180 399 715 14 165 732 66 118 193 199 421 594 986 25 891 512 20 52 173 306 212 683 103 562 351 167 63 728 114 721 19 372 799 53 610 712 722 957 341 649 593 264 193 45 801 638 434 425 178 68 640 698 91 228 291 332 462 986 47 954 527 93 297 412 719 475 3 794 644 384 628 616 803 459 260 488 459 452 290 201 231 419 105 285 94 72 565 223 632 183 755 201 868 301 843 205 371 161 763 611 168 569 40 870 854 323 576 448 583 626 844 353 868 96 178 764 201 945 279 678 858 753 508 845 268 497 886 511 511 173 770 884 637 347 20 483 787 173 757 576 877 77 563 363 566 143 980 563 244 974 753 693 …
Output: 1062

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Ravi's Ledger of stretches - MEDIUM Coding Problem | CodeTikki