CT56634

The ribbons at Duskwood

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the frontier camp of Duskwood. Tanya spreads the ribbons records across the table and picks up a sharp pencil. 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 <= 3263; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 1351 414989 894 670 529 339 612 16 160 600 935 154 305 911 786 299 905 338 257 192 761 271 537 360 854 459 428 393 164 597 120 247 241 603 532 993 995 629 356 135 979 274 988 759 828 211 801 54 454 801 368 507 824 309 388 947 393 405 800 293 577 907 783 388 772 925 605 38 263 554 989 517 68 592 37 194 282 503 355 696 289 86 208 342 865 509 315 377 139 323 724 642 625 487 502 371 169 998 660 948 568 136 242 585 791 170 903 272 45 947 745 977 804 884 235 864 771 329 631 45 997 209 557 141 751 917 514 921 115 61 754 891 847 753 271 376 541 365 600 741 661 419 283 232 116 988 837 276 684 86 137 18 383 26 571 952 452 788 655 230 438 952 433 708 488 502 155 136 225 345 442 341 914 831 292 517 921 915 59 132 241 402 509 951 303 378 271 169 301 664 350 303 571 334 354 381 620 909 918 426 370 952 7…
Output: 827

Example 2:

Input: 3084 503313 104 361 548 152 589 935 858 280 185 131 371 271 107 931 133 689 744 376 488 555 87 212 732 846 487 996 29 152 859 1 152 229 9 498 939 794 330 823 320 334 462 16 392 398 918 550 762 316 42 824 792 981 324 94 929 369 665 692 336 496 271 861 147 541 891 357 217 760 609 571 437 916 758 732 788 78 117 178 357 196 284 630 847 544 31 329 187 931 401 757 970 487 713 643 919 761 385 111 463 496 573 304 83 700 301 416 444 602 768 787 362 572 647 264 579 146 854 744 967 160 8 1000 435 673 684 507 526 618 496 773 119 850 585 8 588 513 2 664 128 119 64 316 853 114 276 411 611 647 943 769 295 626 611 314 872 840 556 596 156 97 20 797 943 371 311 654 364 14 577 348 593 386 235 273 134 54 390 72 733 536 355 545 395 117 419 295 868 448 28 773 170 612 623 763 344 560 865 685 282 796 239 26 190 6…
Output: 990

Example 3:

Input: 2191 176567 946 408 974 756 592 333 854 585 287 647 964 814 870 882 744 459 135 272 936 737 712 837 920 647 197 519 166 553 688 431 130 843 13 780 859 11 203 549 503 239 991 368 222 773 931 679 119 621 420 61 331 887 683 465 71 16 660 772 243 782 318 340 900 96 293 383 299 666 796 414 210 541 194 508 256 254 365 814 899 223 974 168 988 90 663 645 6 832 665 732 761 351 842 73 88 421 135 681 928 254 968 161 904 302 861 814 474 757 102 70 723 513 612 56 77 145 57 958 353 740 268 59 438 143 197 914 67 125 597 157 473 607 995 428 253 178 621 114 24 201 291 358 720 642 9 326 120 383 51 184 248 307 204 290 21 141 124 421 92 943 135 355 304 31 781 459 829 734 876 515 258 558 951 368 989 493 868 411 265 167 426 437 543 707 793 158 161 755 119 71 127 262 801 819 812 547 354 618 823 195 332 337 65 25…
Output: 345

Constraints:

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

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