CT43831

Maya's stretches Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the otter slides of Sleekwater; Maya weighs the day's stretches manifests and starts the calculations. 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 <= 1847; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1294 580725535 731303 707403 526877 208665 618449 604495 207218 828014 346140 948234 429501 56266 182842 183218 234043 24379 187430 632941 746704 333644 190334 662869 168058 660026 703925 260551 602323 403702 415130 948869 882729 900148 99758 586180 480621 65333 119450 191291 395286 360377 567502 135920 166792 18235 591603 772820 742003 612819 828058 313947 612432 8354 40791 519666 731990 910013 607145 577493 111035 166904 711695 552568 76661 508103 539681 205747 336754 634831 312901 160676 32003 342844 551401 445576 277395 505081 938897 168568 530878 733687 59185 717048 640172 760621 417349 695847 818062 651373 412385 141500 232663 486495 964785 773179 51594 572547 134784 517792 617016 524107 235746 378426 730569 674505 657759 610005 9546 309770 865108 216839 925510 466405 989036 376505 3…
Output: 1151

Example 2:

Input: 1145 452128574 853577 775318 92458 436184 855309 43224 981535 395513 611439 73334 897202 460700 603293 351399 484685 174635 102047 57234 585149 390779 294671 442579 226820 179156 801745 61668 637219 989438 554213 657803 25517 121503 907751 157572 107917 676590 102576 807351 86595 433454 304062 329344 277611 552474 268178 809857 412984 516331 653246 469092 354790 731848 809092 684697 935760 704367 941796 895180 540232 3151 702969 535907 953550 535213 55954 829015 904468 627083 478815 575283 385891 578949 409147 533537 423231 79346 680116 140565 743927 312207 532683 324242 349820 770781 452012 637000 265760 305892 413631 709509 22117 355645 451300 476352 372163 359117 726295 297860 246470 59974 695240 652149 384256 573146 803131 791831 71800 190172 239623 557350 813924 472733 452421 278208 9…
Output: 902

Example 3:

Input: 467 68843829 525741 867033 638302 370030 11822 100876 654410 203707 929915 332019 96655 97070 403031 382760 107448 951216 821017 668128 821116 987231 684404 521032 805545 638373 967905 631922 245289 286711 464457 962682 910528 903821 469054 33772 384884 168764 692283 959035 107414 808443 886988 563784 943247 995457 519520 42269 918880 984980 687580 96118 695744 347069 162432 361137 168889 22782 495724 750269 252876 586993 88258 726418 295877 709981 720856 264680 790301 16294 365289 114749 762158 838166 695373 352320 729310 408278 895614 977837 862201 864137 674469 763599 332441 26497 652711 923821 209209 497743 674391 661676 705667 731036 253996 696703 38615 679065 352646 466245 351091 655766 708550 173958 503434 72992 170970 731383 425883 791655 828119 469855 985689 102126 468652 690018 1…
Output: 128

Constraints:

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

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