CT42968

The Tightest Stretch at Will-o-Wisp

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

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

Example 1:

Input: 1022 390298 671 529 777 231 571 501 394 372 672 423 25 846 604 264 737 358 11 339 920 894 10 411 655 106 688 599 521 313 772 726 693 168 160 261 824 454 341 378 58 450 666 746 237 460 21 187 76 49 240 639 183 989 335 513 119 396 228 35 760 174 86 104 872 36 28 725 333 635 501 480 156 567 107 172 152 651 740 643 969 249 489 392 522 124 352 666 592 55 611 101 602 401 227 903 90 826 531 698 778 15 131 957 385 54 19 300 400 364 413 37 184 778 591 327 917 338 114 330 956 252 513 439 893 438 349 894 963 613 397 883 818 638 173 630 702 126 5 188 865 968 941 461 122 333 146 432 575 460 190 742 204 968 348 522 11 145 125 174 417 988 614 181 943 733 695 671 35 229 696 385 45 527 540 431 517 375 411 752 653 827 684 518 412 977 993 831 854 859 218 351 696 523 143 108 350 386 381 150 20 347 904 216 309…
Output: 765

Example 2:

Input: 296 30578 504 115 287 607 952 566 781 436 312 780 433 821 336 880 459 707 892 176 519 603 692 791 870 817 199 578 255 288 397 528 501 540 31 865 207 459 508 918 546 484 321 754 973 578 325 623 701 700 916 752 853 451 924 259 522 40 772 318 449 647 463 163 723 135 111 418 4 99 506 234 626 25 495 412 79 122 882 519 208 512 773 466 87 82 660 850 159 807 170 13 441 773 655 966 326 332 205 380 500 239 905 81 666 356 927 27 2 264 880 442 413 797 82 361 467 351 456 208 770 405 341 352 843 863 566 741 831 44 60 179 349 695 725 413 669 735 455 751 99 163 850 406 697 290 589 780 789 906 738 232 574 951 231 919 638 274 654 937 396 602 215 549 733 287 372 190 834 867 412 788 775 905 466 633 263 828 198 392 726 922 468 928 874 421 803 198 434 129 636 49 223 295 21 945 390 760 969 327 353 485 325 641 60…
Output: 52

Example 3:

Input: 188 46321 893 749 989 927 136 923 142 465 595 765 44 811 239 981 930 599 952 509 805 46 337 797 684 305 940 244 22 356 980 269 457 975 268 897 680 140 43 650 717 266 78 505 826 417 934 367 296 69 613 804 900 75 669 235 511 532 106 311 743 605 864 997 514 39 681 637 843 965 350 220 406 637 294 919 97 72 598 36 48 655 829 693 172 455 422 363 621 946 761 430 435 799 449 577 863 959 565 496 226 365 507 746 400 184 971 884 279 109 669 508 999 265 2 445 135 280 740 690 934 171 395 785 856 35 195 108 32 99 421 762 796 136 757 752 490 680 745 316 866 345 874 944 694 408 75 906 21 898 511 781 29 573 607 828 53 560 36 558 542 935 794 353 100 511 711 222 468 119 969 700 868 932 519 606 160 528 136 126 106 592 386 533 276 406 365 83 519 439
Output: 88

Constraints:

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

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