CT49136

Sahil and the Opal stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Sahil found an old ledger of stretches in the foundry attic at the honey farms of Buzzwell. The margin notes pose a precise question. 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 <= 2147; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 156 18707 596 903 624 292 591 628 470 685 451 461 164 787 818 851 705 215 469 760 528 915 625 781 149 594 710 294 880 240 442 362 841 542 459 826 579 841 890 225 6 267 211 66 667 804 638 471 689 420 749 913 687 217 489 283 903 887 269 227 103 133 107 480 498 227 774 237 604 468 701 128 464 568 321 282 677 569 909 222 231 9 705 958 174 153 448 557 252 262 915 978 487 250 104 766 877 262 890 391 472 965 50 64 638 632 825 235 193 825 771 109 397 610 721 434 275 167 754 897 544 215 867 279 639 113 82 854 85 203 431 46 251 406 497 222 652 806 286 738 746 163 829 414 75 25 615 530 193 454 689 357 432 705 854 346 553 992
Output: 32

Example 2:

Input: 866 339495 134 187 87 119 786 145 772 996 536 130 80 18 909 674 667 892 460 155 228 392 212 621 889 75 20 250 290 583 22 123 623 123 747 52 728 213 812 489 264 924 336 173 796 969 572 327 670 578 354 329 199 463 871 299 799 313 117 746 748 841 408 221 973 235 778 772 189 707 975 433 872 77 11 402 580 304 800 311 151 45 828 403 789 461 51 956 850 912 580 846 966 293 121 239 671 994 185 51 223 253 454 401 230 166 116 185 383 817 171 874 699 790 881 793 606 148 496 926 314 635 752 576 420 804 68 954 934 634 314 771 695 528 360 538 27 363 860 978 439 969 472 204 616 410 126 667 683 54 191 374 900 322 919 549 460 211 211 74 685 293 780 370 694 673 848 414 540 330 743 919 754 32 175 821 157 361 968 888 33 739 800 303 833 855 857 302 763 848 921 673 785 151 742 923 907 921 339 689 112 298 934 606…
Output: 683

Example 3:

Input: 1650 561913 734 271 98 153 38 352 586 180 495 586 150 953 938 503 355 941 137 639 101 67 256 639 317 270 722 865 70 790 600 609 164 930 139 712 415 495 640 834 678 795 551 216 98 680 591 190 779 250 585 85 147 665 951 975 1 87 198 829 52 250 666 104 783 338 478 255 498 331 722 110 358 298 640 587 619 452 338 27 387 971 519 307 820 566 761 477 921 661 307 463 388 493 363 434 602 500 840 506 190 540 342 659 92 944 365 383 81 415 437 574 461 519 137 911 748 306 809 996 993 763 552 60 296 672 472 406 45 586 566 903 517 233 15 752 673 75 698 640 203 794 753 509 315 666 782 476 689 814 439 777 859 451 362 587 116 373 826 539 108 618 21 314 133 618 823 410 672 225 783 921 593 561 1000 316 751 320 627 345 133 610 789 936 89 219 698 851 248 6 424 174 97 158 89 395 429 432 457 986 912 551 686 12 310…
Output: 1143

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Sahil and the Opal stretches - MEDIUM Coding Problem | CodeTikki