CT55027

The panels at Lodebarrow

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the silver mines of Lodebarrow, someone must plan the beacon maintenance rota. This year the task falls to Esha, armed only with the panels register. 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 <= 3613; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 3300 704793505 435923 280681 116258 514639 434139 769747 412564 391725 326448 724559 914892 897055 744259 454675 990554 834968 35119 911627 838742 644074 933777 315802 287152 823916 620476 644681 348469 642720 813226 313401 144868 396602 580423 311023 412468 414437 905577 490082 313760 545827 285780 414405 953759 608992 964390 3827 195720 241569 356191 674833 506773 208631 691051 468211 729991 434246 808717 811996 285275 377473 731151 998166 395542 311820 298832 823348 524978 675076 217313 30229 52642 872629 552691 525012 583420 795632 802474 538697 105716 584843 505614 314945 214576 153047 281410 872680 363018 945729 84238 688239 376683 855047 69989 512021 144706 943038 37825 172875 106065 823496 807394 822543 343445 472532 669569 52157 183612 392661 175056 647360 402831 740923 752571 997…
Output: 1382

Example 2:

Input: 2764 198304567 133355 831354 203007 427849 218285 538853 105615 951838 839455 171132 545073 421203 255783 596760 128395 794263 9436 433373 126060 879621 157420 438405 120862 432162 16420 976042 658281 792639 450576 578667 583959 691916 752818 230839 599171 179345 751874 213047 938222 712667 577619 800238 833406 640482 707327 640002 207645 933641 915807 787526 181913 729582 229744 734637 460950 892030 582872 989580 44503 620692 84996 989674 357524 752004 304758 315723 78 703685 257532 439995 936948 970791 967854 312229 400843 777037 20781 333234 935915 306978 879452 61028 203228 878537 554163 607332 899887 523324 468993 847076 649339 280695 840721 506349 798931 878868 77852 766934 462390 459237 427877 546732 765299 134954 447490 997133 715236 714527 277251 249251 483566 962444 441031 124396…
Output: 378

Example 3:

Input: 3519 78559935 277670 459972 124450 93850 97621 714305 656327 929972 607875 784052 198850 971481 16911 85360 930104 217666 172708 259568 186191 417429 526802 852806 192694 591085 825079 511620 877682 450484 309824 412839 954807 453993 683478 841301 796201 538513 517003 59066 417368 924486 428284 663963 406509 338004 248051 918727 466514 154292 855941 22511 796627 305116 155387 543838 733280 326343 403746 135659 493057 73685 132034 467018 439656 292013 473798 449881 472579 847853 380072 508855 703336 985970 649402 889178 31051 359228 281708 981621 687276 370224 788818 533672 498380 578065 379456 172793 632831 109480 617284 116287 346817 187284 30524 390194 448399 82358 104756 681794 870059 677615 367349 624130 76303 60186 50107 534763 537373 104938 808357 81632 917515 89096 920424 80352 3826…
Output: 139

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The panels at Lodebarrow - MEDIUM Coding Problem | CodeTikki