CT46047

Elio's Ledger of scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the saffron fields of Marigold Row opens only for a perfect tally of scrolls. Elio 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 <= 3781; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 166 72219881 499051 416314 414209 554859 7489 225674 981601 281864 181172 554581 788039 878837 114495 467712 655357 832866 475568 647677 224599 347886 104118 643252 793745 19126 739317 96275 270438 144417 685751 153645 164400 535375 577057 632889 992151 701108 633119 264200 347595 930399 303263 708859 690493 183394 352978 167171 67774 113103 179932 727944 47334 714185 595085 26470 774687 750450 623716 275789 327257 976256 758686 366777 978506 230167 458704 125525 267746 401053 375193 819325 351359 239861 33399 578215 406409 406005 728602 828631 86518 429012 147376 330961 925475 595805 792715 821160 749006 103712 828369 882273 243250 349421 401713 514411 15992 920487 273368 760350 738215 160 7229 270423 120160 581349 395188 915752 546504 392248 463279 948873 783803 636489 746835 147609 8425…
Output: 153

Example 2:

Input: 2831 209585571 605716 885831 719894 812113 496622 79376 599490 457253 402286 441769 940181 273271 738899 640764 714862 2705 523975 796470 151689 266016 231274 59681 744178 612223 76927 244627 314157 905159 870020 492568 248229 893051 174856 480928 520325 431870 329819 235536 711603 959548 949246 283450 48570 564273 797294 399476 212361 291106 998472 557903 67818 475396 776802 587991 227901 553629 895933 691594 911559 827434 118259 178662 846613 165577 486870 52934 721193 126085 137269 307674 660214 163787 976832 581674 810293 18439 729638 257580 626604 146330 595079 322289 696024 108073 661118 71093 392341 532508 409087 594189 888399 183001 155291 401366 688638 903352 256727 973357 772430 264639 14139 275289 816268 72875 685625 378059 157109 138595 496253 980078 179005 130349 423709 286425…
Output: 399

Example 3:

Input: 1653 344401408 709973 564868 111137 70168 818053 389614 229155 567664 336137 871509 16811 126852 922768 64620 571710 361438 87442 300269 601814 677742 248033 247684 639265 345971 772180 476466 891091 891954 544007 500975 577718 944924 253734 808418 744419 16562 522925 706076 7160 925356 551502 488091 349094 203869 171838 366257 564426 562890 612877 956924 677713 122546 530205 55932 711410 542352 199028 698062 679078 688234 39177 78201 632494 802046 236432 588411 267856 577890 258590 105789 988076 798693 829773 918989 852806 20880 648971 928507 460968 528219 874021 132183 367250 649610 748999 851740 466179 302507 519813 478082 585262 667113 1387 175587 326075 288406 280427 70114 205752 976298 206370 912935 339734 627807 25130 516161 975759 415229 243287 74590 343209 634234 603188 653819 926…
Output: 679

Constraints:

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

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