CT37537

The Tightest Stretch at Greystone

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the shale slopes of Greystone; Gino weighs the day's panels manifests and starts the calculations. 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 <= 2345; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 1177 112863 846 282 9 277 422 69 543 774 83 201 397 287 319 918 660 178 789 224 821 223 86 870 345 121 230 122 856 677 358 19 983 701 323 870 423 74 527 741 617 889 505 199 713 655 319 683 193 612 420 657 601 533 855 17 280 532 354 478 982 139 43 921 858 894 813 726 692 555 712 283 682 518 99 652 946 638 63 45 254 890 145 93 613 140 466 724 436 421 6 928 253 931 645 383 532 843 591 145 148 639 51 467 6 885 198 888 975 213 691 37 445 96 695 160 49 393 750 356 660 522 613 408 4 797 651 919 28 331 601 935 690 554 134 49 131 961 397 161 57 994 63 362 284 907 187 15 339 598 18 829 640 865 152 405 270 934 332 182 946 806 576 610 608 132 534 649 743 635 397 287 936 638 607 488 94 938 31 925 228 179 367 364 963 683 780 775 637 390 171 108 581 843 446 58 963 405 356 713 396 360 636 857 366 643 699 …
Output: 201

Example 2:

Input: 311 151801 228 718 893 386 699 605 794 98 882 349 752 518 935 287 592 864 454 95 319 967 209 424 971 599 643 303 758 73 208 465 269 931 618 243 369 105 859 133 992 369 693 231 203 443 896 775 896 18 18 590 103 386 673 485 870 905 16 570 510 727 163 251 835 801 569 879 433 207 911 545 9 834 219 307 18 606 79 396 134 374 564 321 263 98 748 997 533 460 634 255 548 223 840 987 769 990 311 530 365 975 106 252 926 300 280 45 537 909 101 726 353 302 268 595 72 723 256 381 656 124 306 837 39 165 968 8 159 759 858 982 548 582 353 395 160 568 338 750 192 628 428 649 534 440 225 761 601 225 228 402 417 972 44 974 86 76 505 380 654 943 326 34 715 123 438 97 801 458 835 538 825 677 245 891 724 767 141 380 787 303 698 380 404 785 806 838 181 913 172 319 346 12 194 529 656 749 380 1000 776 318 583 410 14…
Output: 310

Example 3:

Input: 1601 746896 762 407 713 829 306 916 10 275 638 298 660 258 402 449 346 347 853 508 526 914 540 688 420 195 631 579 71 73 719 207 9 513 2 79 246 774 219 459 256 510 38 222 326 416 473 538 479 632 436 235 267 568 817 887 552 997 253 752 878 797 340 683 286 790 268 403 606 492 195 608 220 970 626 270 538 568 827 260 527 352 613 20 946 300 298 952 349 220 386 415 443 311 253 539 805 463 89 507 216 921 702 358 462 800 202 202 236 56 424 945 674 190 935 762 878 314 16 410 347 498 145 910 315 377 47 368 532 367 380 707 701 122 24 465 152 808 218 37 528 355 484 58 297 35 821 111 915 938 414 726 968 380 753 372 399 243 649 117 24 240 653 11 165 406 575 833 45 676 347 351 896 248 983 558 925 662 119 142 515 413 963 538 890 557 471 578 906 386 34 352 218 561 959 941 795 453 716 68 603 209 496 114 976…
Output: 1504

Constraints:

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

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