CT51640

Kate's Tightest Stretch Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the caldera rim of Firewatch pays by the answer, and Kate intends to earn it. First: the full register of windows. 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 <= 2834; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 104 4271283 312709 47261 507400 46803 11843 377889 734187 724291 841813 389427 131872 333658 221386 67001 769424 802639 784690 601296 218404 936226 408272 554041 523564 517800 713069 428416 34948 266828 861829 654082 916219 436189 673299 493457 813847 808927 482577 712184 290819 604803 357956 642439 611154 101293 892520 980552 274178 417382 206006 302081 780279 170263 928942 836813 779854 314180 737071 561371 957874 103677 654361 944850 895711 44482 950696 950740 816701 15970 890181 730139 22228 104810 285094 106144 158605 821279 294903 764958 100745 1851 651404 376716 143248 521042 240851 832663 280907 444678 530996 878696 164520 377957 203538 425879 934677 766460 830837 526603 339395 80976 190179 455568 701325 822231
Output: 6

Example 2:

Input: 788 125319058 742921 597872 389997 652683 338086 218224 855963 696724 354261 910917 164455 640613 616315 245083 965769 496199 789427 130144 743477 635238 907800 469789 978084 760152 851707 898418 947504 339995 260669 958230 955924 358816 188239 913149 413952 192415 528945 735739 564209 619972 897737 110738 191978 838218 301252 840903 564666 622756 428903 399718 528294 8629 206965 827035 945655 149416 840876 860137 4738 986578 322158 271798 428872 219338 366518 348969 586966 276820 737536 742297 996827 936562 346270 35697 798796 734619 144200 789044 292624 578692 798419 120989 576208 672816 884411 566068 441486 944659 253165 925989 128747 720670 157974 877508 83957 116674 606606 678404 848564 482405 538276 587533 869650 628027 89949 724424 897928 167165 920144 197495 289071 81012 65909 3897…
Output: 225

Example 3:

Input: 476 223592624 740522 393195 28926 12471 121877 556528 466258 880772 271819 29396 699845 959565 504888 633774 322291 103657 65727 394636 531973 666258 935157 1266 450656 938208 10832 125986 241013 704995 650073 469716 11714 287366 164468 440475 877534 82438 726084 30724 947108 288547 510946 494539 521804 345494 843544 138246 80812 505055 980928 725156 564602 18745 455894 100173 674119 401649 240209 920967 378099 670493 203503 242432 675358 124862 173082 716766 59295 929000 283926 211502 199141 534515 899328 588461 784273 984921 114350 334319 188138 669043 612208 901238 884997 663716 85777 218654 751614 402578 137390 786186 484830 151612 725132 334368 699451 211122 250577 813744 126915 546501 127823 27518 914586 466291 426647 214107 146022 346124 675270 222974 37122 472779 293126 474643 5442…
Output: 449

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Kate's Tightest Stretch Ledger - MEDIUM Coding Problem | CodeTikki