CT42092

Elsa's Twilight Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the mulberry rows of Silkmead opens only for a perfect tally of windows. Elsa means to find out. 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 <= 1938; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1016 464569073 141122 68958 75935 792064 398712 231911 939106 527147 772585 368830 584666 34395 3506 33200 849692 806092 456854 34869 613186 844512 412887 230455 705448 12040 984523 105225 49979 666921 853368 200869 659279 452168 366364 159629 178634 795011 774481 860604 519811 837623 692643 727245 875283 951809 788585 361361 331931 192568 264099 550882 179419 722240 407867 673884 938178 708696 707758 638906 780524 470302 195977 567140 856149 300631 19533 90968 870528 546014 168227 385104 819590 93110 994140 971141 797101 361656 724757 674594 823783 65105 651190 265015 172192 869279 665989 378172 782085 13216 887362 279062 421499 501482 803622 841742 163342 875971 922843 844708 803563 359228 633205 649448 385525 180604 573977 779807 893817 844488 981738 308708 986972 827790 834359 273085 9…
Output: 920

Example 2:

Input: 212 67493846 448834 474212 132105 691311 800347 871270 759384 99836 601756 642504 64554 102128 607246 802459 472 492298 226563 593610 52787 26897 190043 945708 699008 832843 450952 793812 942212 305904 85051 249588 851184 551970 371636 793653 399759 544581 12877 99334 870798 466782 477355 518248 120848 231124 744499 939778 579335 515252 732009 950990 686539 42678 615472 106748 704890 412942 391263 157945 59956 43553 771058 449988 888547 849961 356206 775701 842313 57816 560042 783443 550965 102074 323876 108503 833749 257409 999867 840611 191401 829192 208022 195441 434580 729972 111321 703707 537968 125091 113842 394164 272651 788213 852013 368851 450767 417605 289106 863448 601504 506321 232508 279905 590880 705919 582748 425362 695115 869442 613775 40452 14056 390736 299953 460145 76166…
Output: 131

Example 3:

Input: 448 134615875 931302 230136 4087 838517 226104 786372 818553 124113 965874 195765 945686 151905 317263 304468 625013 92916 16975 313305 208941 138742 580818 120101 223177 130451 729743 703820 499625 426781 688600 375624 817088 91526 412451 614094 958488 227379 5788 153938 397141 811968 730583 281193 564854 8418 563321 161649 61195 308773 631481 198593 439063 260789 770609 10776 793666 44939 430044 989765 8088 81397 950726 126951 877970 883782 30996 10697 31942 389745 226392 681301 582008 367257 935239 912629 420614 421425 700390 928954 61649 766608 422437 403522 971293 860147 58269 262642 82561 752490 247258 407302 713272 140316 723576 48084 550701 590244 154133 291390 919690 794867 364995 467898 147895 556088 556194 12236 83402 759844 612978 597130 343858 130993 922074 528710 101090 38576…
Output: 264

Constraints:

1 <= n <= 1938; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Loading...
Test Cases:No test cases
No test cases available.
Elsa's Twilight Ledger - MEDIUM Coding Problem | CodeTikki