CT56704

Pavel's panels Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the windmill fields of Gusthaven close for winter, Pavel must finish the panels ledger - one figure at a time. 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 <= 2467; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 2321 1076038 857 142 155 475 588 955 615 212 15 403 203 339 428 439 925 413 666 270 774 674 418 195 794 247 27 203 135 589 327 892 283 133 196 622 821 330 104 277 551 257 210 169 930 712 621 499 777 507 363 750 896 811 396 582 30 266 971 516 826 734 618 592 999 388 401 750 893 286 493 375 790 25 487 135 579 871 697 436 547 583 956 501 998 495 148 501 350 972 519 955 324 792 445 360 772 467 87 606 723 914 457 695 253 349 586 700 914 188 231 632 333 685 586 633 895 79 764 377 601 181 259 321 765 232 395 680 805 217 957 658 999 147 92 681 188 873 927 716 246 36 490 191 937 161 808 717 696 646 481 360 836 914 564 676 13 279 57 775 924 553 497 172 469 704 12 489 784 349 523 225 895 313 202 548 376 931 581 561 672 227 370 543 924 216 556 266 669 967 496 685 722 180 824 532 148 662 347 933 331 73…
Output: 2102

Example 2:

Input: 1070 323628 47 482 140 212 224 331 389 344 296 230 975 856 365 570 509 723 768 675 101 794 565 43 486 450 185 809 297 30 358 873 998 288 609 769 89 670 292 770 12 691 165 812 13 105 60 216 754 914 736 321 835 623 782 877 757 852 80 653 744 949 740 367 412 778 125 398 155 415 967 965 842 139 973 637 593 277 489 550 467 592 72 329 240 95 628 861 108 608 664 379 418 567 549 551 807 56 616 875 709 998 378 494 142 847 772 557 588 827 942 830 30 410 755 895 397 894 274 108 457 988 512 879 784 917 971 529 173 318 59 29 611 75 715 699 955 329 62 70 118 835 517 96 923 945 976 680 920 167 145 573 260 269 264 447 890 637 432 244 150 139 96 988 352 900 157 547 740 779 21 856 686 113 423 287 843 815 444 883 529 458 920 686 447 895 120 223 253 292 439 413 634 105 825 745 78 6 917 590 688 362 774 127 757…
Output: 634

Example 3:

Input: 1838 136178 797 69 322 744 622 808 61 412 656 340 723 929 91 36 438 953 481 983 953 371 291 280 970 329 32 754 429 78 735 254 11 503 917 718 651 37 392 576 806 286 245 662 570 600 46 711 483 568 818 971 361 577 975 32 6 51 319 960 566 526 748 354 465 312 310 943 558 427 100 25 516 444 553 808 461 659 123 709 220 524 387 650 385 754 430 676 736 184 87 712 533 752 775 98 819 281 737 11 832 619 102 129 179 124 389 724 923 728 467 653 88 495 433 903 89 196 402 561 355 321 500 1 520 469 898 327 167 277 387 790 58 183 143 981 829 251 316 54 849 34 986 378 817 803 187 146 931 766 495 345 749 413 785 727 917 916 588 666 628 704 870 651 875 247 554 43 9 169 770 996 261 726 745 68 180 879 102 88 751 335 262 376 727 611 539 729 666 458 684 47 761 25 541 818 774 917 661 506 120 641 472 946 18 634 958 …
Output: 255

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.