CT36398

Freya's Polished windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Freya found an old ledger of windows in the greenhouse attic at the glass towers of Prismhaven. The margin notes pose a precise question. 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 <= 3314; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 2313 980952 894 888 932 116 720 632 980 275 774 766 733 491 222 478 976 51 598 294 932 639 316 12 29 434 638 937 662 497 52 33 703 39 500 995 146 348 129 457 554 101 218 10 922 12 443 639 781 504 279 905 965 870 682 133 724 466 794 567 926 573 541 911 182 917 21 621 773 242 34 268 588 723 157 970 213 331 624 321 239 528 561 230 339 431 745 384 770 362 173 59 173 636 661 163 970 821 949 723 227 641 468 949 795 825 815 13 831 364 945 640 817 73 500 956 274 479 846 910 960 438 29 943 285 59 430 2 763 336 482 7 506 562 42 22 966 140 810 935 821 482 325 548 647 944 936 483 134 635 610 781 755 866 189 261 498 46 622 264 345 85 820 175 967 484 453 616 795 957 61 649 159 346 660 157 194 414 477 937 951 309 870 249 91 668 134 917 838 328 261 664 420 665 570 38 690 595 599 525 410 982 776 358 769 12…
Output: 1923

Example 2:

Input: 1062 513504 449 503 155 804 420 425 913 914 972 257 212 735 824 127 357 686 754 428 968 243 121 480 270 839 346 814 89 295 26 370 89 558 682 362 179 528 726 649 29 696 968 960 910 799 774 785 282 489 728 529 282 438 562 687 104 606 356 648 879 984 45 618 960 174 833 827 167 26 392 261 461 768 102 347 392 837 825 686 94 109 547 789 699 70 264 464 622 311 573 60 516 847 383 566 831 807 371 951 340 55 459 596 735 436 468 650 803 993 857 851 427 676 470 552 52 964 626 407 584 756 538 145 632 566 884 25 212 705 382 832 683 493 670 618 799 337 220 972 429 555 480 152 260 726 187 856 518 700 581 13 344 465 701 114 151 703 591 821 436 669 589 466 321 905 579 442 708 139 489 59 584 950 619 729 573 333 367 547 427 59 690 285 770 537 965 75 389 584 174 951 929 487 577 320 412 744 488 660 290 410 379 …
Output: 976

Example 3:

Input: 2249 339360 675 590 926 128 39 243 598 894 779 215 646 352 721 919 456 679 46 57 53 744 294 971 227 16 998 560 85 667 851 132 91 630 452 907 645 509 366 872 82 708 831 25 129 837 605 26 963 971 953 708 44 654 814 230 653 64 981 979 541 930 614 579 556 110 150 778 33 348 552 692 75 318 220 489 666 809 377 527 205 206 395 291 439 178 674 572 628 732 385 578 959 671 976 116 479 935 46 165 235 227 906 666 903 531 906 306 857 252 168 49 709 921 662 928 504 923 412 261 905 713 446 962 886 251 892 661 299 704 314 275 850 619 338 268 583 101 925 201 509 155 133 695 807 127 71 903 654 116 395 76 75 118 278 156 212 263 208 598 394 948 67 9 752 304 54 986 147 862 430 471 710 919 554 576 370 883 98 793 416 275 859 606 410 972 3 849 743 747 541 258 183 712 868 580 841 554 188 339 658 682 300 678 381 27…
Output: 662

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Freya's Polished windows - MEDIUM Coding Problem | CodeTikki