CT56895

Secret ribbons Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The factor Ojas has been asked to reorganize the archive shelves. On the desk lies a long table of ribbons 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 <= 3408; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 2084 848391 98 626 889 741 180 450 396 27 441 831 61 818 111 70 53 896 885 939 158 449 289 451 812 407 73 446 155 490 283 526 212 28 409 140 366 265 337 854 443 159 383 531 727 207 263 692 399 198 957 907 611 200 590 755 161 584 251 577 672 635 467 634 413 83 269 746 341 881 911 576 25 848 526 346 736 47 513 107 339 685 855 344 938 586 960 680 999 238 311 164 774 333 222 430 370 418 553 467 819 273 965 664 416 477 287 875 883 309 573 830 449 780 173 115 669 553 223 121 264 933 327 891 153 127 986 559 464 234 725 704 519 893 218 508 584 931 129 847 882 723 976 639 268 84 430 627 838 167 412 765 678 879 784 56 3 683 538 795 343 496 704 646 88 379 749 774 164 436 22 757 684 736 54 551 802 127 531 275 92 984 777 949 916 962 158 745 662 885 174 427 705 301 806 605 684 811 715 97 22 224 74 902 4…
Output: 1679

Example 2:

Input: 241 107770 376 595 344 597 317 855 510 145 75 823 73 726 289 473 827 2 443 66 847 106 228 507 555 347 89 814 273 794 974 169 160 237 324 136 656 523 112 206 768 767 695 773 765 492 370 659 656 271 832 85 321 582 167 301 283 950 225 988 862 123 290 432 758 443 387 739 368 477 414 550 314 962 391 136 141 302 516 525 990 537 620 264 748 355 940 385 493 295 413 634 152 84 547 192 786 621 49 260 662 316 554 805 287 307 41 63 589 261 578 746 608 970 993 302 846 453 949 379 858 736 124 151 269 352 899 372 427 379 980 840 166 464 648 591 57 588 771 529 939 181 455 631 245 90 304 131 710 336 874 546 10 437 503 270 998 879 150 624 806 279 15 962 308 391 114 210 93 681 600 165 947 304 137 479 64 643 367 268 801 431 690 800 767 396 483 379 305 918 561 824 953 120 96 763 58 28 529 63 180 587 561 335 88…
Output: 226

Example 3:

Input: 1152 221942 89 916 697 150 268 725 57 91 386 951 618 85 883 136 175 555 601 957 665 641 539 56 45 185 644 765 64 951 609 112 887 948 595 318 274 324 462 593 906 182 867 417 477 718 125 434 340 692 138 291 883 942 77 480 497 291 582 903 535 659 634 811 854 653 173 737 309 527 67 967 495 799 779 561 529 576 339 675 403 477 529 719 188 896 936 635 260 888 240 99 431 800 441 93 490 706 36 119 584 219 449 637 441 872 124 378 789 68 106 179 102 885 236 2 785 870 658 267 382 540 982 95 547 301 949 997 429 37 859 139 489 498 527 338 580 871 230 368 455 839 337 608 805 692 676 288 298 538 410 134 672 167 411 785 759 958 660 928 184 20 879 23 571 571 282 953 292 101 595 225 667 248 769 919 939 61 770 782 955 891 144 982 183 695 954 71 966 833 824 241 500 173 702 716 262 445 254 89 678 415 51 453 708…
Output: 426

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Secret ribbons Tightest Stretch - MEDIUM Coding Problem | CodeTikki