CT41044

Odin and the Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Odin the valuer watches over the mulberry rows of Silkmead's stores of scrolls. A careful computation stands between order and chaos. 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 <= 3058; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 511 141433 705 216 988 367 196 451 504 671 452 612 361 841 469 959 421 261 864 154 942 315 17 345 923 608 861 52 588 650 237 359 306 366 28 912 380 637 881 945 971 2 249 72 446 505 435 597 587 576 305 351 748 420 465 306 194 722 236 52 608 115 918 266 547 281 214 951 948 265 927 784 275 589 631 195 127 717 610 820 165 717 352 451 616 534 34 677 459 606 825 47 783 242 333 192 686 761 966 258 205 689 944 43 353 394 492 631 734 596 886 682 484 314 407 418 668 497 550 56 578 491 618 286 976 672 971 624 294 886 943 956 709 83 330 901 211 970 262 225 825 851 143 45 493 950 258 311 537 304 223 106 301 764 352 865 964 776 311 942 861 239 265 420 581 778 203 264 727 340 1 844 30 236 103 387 838 247 723 517 483 376 594 132 101 368 395 893 261 677 216 686 144 756 998 4 539 606 718 655 541 810 218 649…
Output: 287

Example 2:

Input: 3023 1335025 289 463 537 954 896 256 913 515 391 13 337 67 248 85 695 874 294 875 280 657 175 65 721 446 326 874 141 840 142 868 357 581 201 494 555 696 283 125 425 897 741 158 130 72 558 618 698 355 202 754 863 963 412 31 843 893 585 775 263 160 871 879 760 857 790 630 720 938 339 234 839 120 871 53 766 337 387 161 526 572 661 231 371 939 90 468 621 895 717 740 406 797 681 641 39 712 291 242 35 248 674 555 736 68 986 243 884 765 490 734 747 768 787 442 100 364 147 35 619 995 354 605 110 729 237 276 579 315 606 573 847 657 621 534 831 471 573 976 767 776 53 509 673 795 198 385 682 602 760 29 162 810 390 355 365 427 401 570 562 831 75 300 930 346 900 564 680 331 427 827 757 722 15 785 527 247 855 600 64 90 991 366 662 482 574 903 654 605 197 47 651 668 278 66 247 596 477 914 552 543 747 753…
Output: 2675

Example 3:

Input: 1462 112744 878 846 772 794 342 131 691 520 230 19 636 691 26 294 697 125 849 341 628 690 602 185 216 83 959 426 347 58 963 586 171 830 442 107 84 178 898 970 32 172 894 291 627 610 449 298 126 218 50 595 60 222 769 998 543 256 429 267 513 356 459 30 91 329 370 223 763 451 858 198 844 453 692 92 380 700 911 697 347 317 674 717 170 116 857 648 445 999 104 519 165 182 636 322 955 75 521 919 285 755 492 272 457 842 247 769 475 615 143 446 75 631 675 146 130 594 326 164 295 521 780 816 567 852 730 50 624 777 136 391 392 713 821 915 152 100 520 179 430 722 449 264 547 335 786 414 111 588 739 982 36 965 325 174 845 31 856 999 276 700 49 756 735 834 37 217 747 966 725 634 648 647 132 843 871 930 447 25 141 541 483 733 688 715 484 804 958 267 489 400 998 642 10 609 236 37 381 789 194 542 237 783 7…
Output: 211

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Odin and the Tightest Stretch - MEDIUM Coding Problem | CodeTikki