CT52739

Lila Counts the scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the ember dunes of Ashfall, Lila studies rows of scrolls entries. One clean number will settle the guild's oldest argument. 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 <= 3350; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 2089 417147 211 719 102 301 678 714 995 501 158 726 606 354 57 468 998 920 200 550 471 338 751 943 855 856 423 58 369 219 952 365 970 911 36 101 524 75 850 387 416 971 125 249 585 158 521 585 648 149 512 966 65 337 463 889 410 909 73 757 426 21 259 199 626 262 907 298 826 793 700 378 997 614 379 111 455 362 614 186 89 980 838 253 196 990 220 992 863 299 798 204 368 455 294 141 809 855 537 955 369 110 494 178 51 710 255 565 331 988 963 164 182 978 832 898 294 290 173 510 724 611 589 864 858 873 778 978 764 940 168 28 36 812 217 108 529 278 828 496 540 618 538 289 409 934 433 976 345 115 660 644 365 832 318 840 868 305 893 482 667 142 556 421 292 757 721 276 15 70 128 991 842 410 971 871 189 487 746 523 189 32 93 178 640 879 276 535 146 831 602 700 924 365 403 165 882 875 59 328 552 217 196 …
Output: 841

Example 2:

Input: 3286 1238988 757 75 755 597 380 210 668 492 693 333 573 679 624 510 458 53 860 579 122 502 680 776 362 472 33 573 540 252 548 281 405 187 362 35 384 922 590 529 9 152 257 175 281 435 314 648 562 449 810 93 443 343 625 75 176 807 937 261 654 271 42 967 734 20 334 137 835 503 678 721 786 536 569 959 215 397 823 846 552 982 384 854 459 882 316 518 222 139 424 637 862 474 779 820 371 486 173 391 226 397 41 395 518 258 856 764 178 2 918 635 447 104 256 336 239 614 980 755 122 902 711 797 653 422 856 822 578 870 616 568 797 433 944 647 893 391 94 794 617 33 159 296 692 425 960 697 50 112 914 548 730 48 100 222 589 558 506 916 621 106 251 466 699 137 568 125 961 48 706 809 6 277 264 854 975 139 17 444 446 348 339 421 806 409 809 496 32 30 756 379 497 62 832 878 432 370 962 396 235 379 134 337 274…
Output: 2492

Example 3:

Input: 1322 200933 90 662 466 600 460 706 360 231 787 921 457 148 288 33 71 942 640 497 461 646 501 117 59 607 76 971 800 594 347 403 287 678 426 24 157 72 460 48 367 483 329 721 243 231 180 456 27 625 245 984 718 991 779 161 881 947 937 481 304 519 841 124 106 600 353 807 237 420 668 967 203 247 78 428 518 791 854 781 194 730 211 25 880 241 785 496 258 900 278 46 790 538 463 108 927 748 863 59 112 901 795 894 822 869 770 347 259 107 767 733 100 865 515 961 893 89 503 888 617 786 334 867 8 293 154 269 668 7 329 672 93 851 672 755 358 639 543 194 30 613 298 207 286 793 887 167 327 789 791 907 43 395 516 848 609 716 128 434 232 174 758 814 381 532 244 423 490 311 781 118 690 576 854 798 375 975 751 454 697 415 724 845 483 833 725 521 942 690 68 199 7 112 897 114 659 82 794 265 862 765 561 740 886 1…
Output: 386

Constraints:

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

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