CT36649

The Tightest Stretch of the Wistful windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Zaid runs the timber yard at the clockwork quarter of Gearford. 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 <= 2280; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 1510 616872 518 435 223 803 714 422 794 286 65 991 94 727 525 96 357 477 359 622 727 218 516 966 741 256 186 449 327 493 454 251 439 874 320 946 443 614 822 949 249 113 582 581 580 356 157 332 519 514 139 887 790 763 342 628 413 966 448 415 984 318 125 537 772 627 11 991 199 441 43 601 943 185 715 935 973 900 579 572 490 639 919 324 199 269 478 342 28 647 866 135 774 811 116 903 266 582 836 801 585 41 834 548 728 434 480 511 198 638 475 677 766 848 689 84 362 283 372 704 793 504 617 925 877 447 146 554 674 174 220 294 176 657 179 494 86 551 314 590 991 743 493 621 370 826 95 586 895 375 608 824 64 185 731 986 966 588 862 633 206 225 360 670 886 509 926 602 507 926 197 100 590 402 798 236 730 611 368 628 332 213 67 577 23 207 685 276 633 483 843 481 478 22 764 609 95 508 58 632 74 978 820 4…
Output: 1278

Example 2:

Input: 595 58573 399 28 293 126 681 595 927 144 367 4 971 151 127 602 431 613 232 355 22 401 764 673 926 849 731 848 790 6 325 178 579 419 718 928 406 191 489 188 35 560 15 574 356 710 654 300 745 14 297 578 126 184 334 699 788 81 464 695 611 769 864 220 735 21 682 30 96 223 577 869 858 320 219 4 300 930 680 99 100 564 977 566 357 493 887 966 818 481 204 342 298 537 514 524 830 96 262 811 949 733 980 973 442 464 792 333 591 856 537 830 380 916 107 182 582 97 656 698 923 257 150 109 840 257 382 350 624 608 2 908 548 683 458 691 471 210 597 3 403 506 851 683 311 404 614 466 935 964 459 144 884 170 345 376 539 820 757 399 196 784 277 583 491 694 710 763 858 5 120 614 749 315 862 656 220 649 156 519 665 6 997 386 178 725 784 563 244 634 606 719 67 748 912 131 592 358 419 275 469 49 678 26 598 55 742 …
Output: 109

Example 3:

Input: 650 102867 930 915 490 863 473 41 238 652 505 424 988 804 558 793 237 401 132 164 437 77 332 254 158 623 724 343 283 897 947 252 454 105 184 350 776 723 439 846 360 662 534 66 707 965 138 732 290 443 710 73 697 736 515 154 462 896 940 95 1 632 120 929 824 366 771 580 712 854 71 142 502 956 275 446 694 601 317 911 215 519 72 38 931 472 605 460 585 199 227 497 313 451 6 416 162 495 595 484 111 391 455 461 472 661 663 146 901 544 66 90 277 611 351 942 475 56 161 644 493 725 690 547 688 468 884 185 785 763 20 190 493 224 661 477 132 553 487 212 848 145 726 552 151 953 849 1 267 803 176 507 738 938 333 567 783 946 987 137 392 845 750 471 465 638 546 280 957 292 569 922 423 727 164 271 868 852 608 208 120 367 479 336 553 100 892 14 633 958 417 327 994 247 909 824 736 393 323 785 638 505 525 998 …
Output: 197

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Tightest Stretch of the Wistful windows - MEDIUM Coding Problem | CodeTikki