CT50919

Envoy and the Opal scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the lily shoals of Padmore, Envoy studies rows of scrolls entries. One clean number will settle the guild's oldest argument. 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 <= 2914; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 357 563610 729384 278685 703021 55772 842517 221823 761711 136305 661220 782635 206742 198490 696337 70940 160198 588638 14001 385916 947090 829574 389308 141642 625556 644653 690243 624540 3551 749025 760574 660752 714562 575383 250525 585182 588711 1580 908422 312092 383864 606730 198808 889656 846942 44569 68974 812712 7522 555379 510691 831185 797655 202873 592854 156406 41149 995057 309616 593774 385554 328494 867948 375948 435711 349147 134750 265038 32297 583216 748272 109928 675643 561630 754824 100033 503358 22805 357056 435466 194240 873400 120990 332856 4682 274717 12699 416664 845236 885775 405762 879971 593204 948401 726909 834266 375928 463059 670999 80556 195925 542978 341292 272940 451371 653375 966693 824228 757598 656809 325095 744476 388988 885468 177609 801715 228069 61…
Output: 1

Example 2:

Input: 2417 223936406 4792 309150 985844 651572 720258 438600 809396 610563 948144 675485 191098 799789 60760 308481 92180 918158 393035 979265 565394 413729 374500 69667 501489 1841 927418 509 163455 286029 521251 99273 927016 544724 569197 280527 897433 26724 912417 602263 170292 858427 782764 100413 295879 951446 216917 446900 691590 984385 243031 410657 380633 91978 777932 463914 945732 21255 471003 979800 870948 847994 408951 94485 896851 58725 297421 114319 32103 621642 807898 172314 94565 484129 182576 669172 193505 923059 932111 456513 420263 832917 793040 196101 981026 656923 199994 108950 896426 492615 2735 18387 225870 528618 281293 378800 456316 980861 5213 31854 120371 235709 627485 41593 752179 753135 884528 899438 300104 963984 830209 182368 639333 513615 696168 495400 664888 62562…
Output: 427

Example 3:

Input: 83 13132939 211419 813703 244721 165954 582443 511137 189393 163938 68890 170024 593730 450670 923343 724561 955797 114018 299515 329694 51364 185665 486719 850962 602542 951085 859916 698980 770322 951263 263876 858878 652069 71854 288447 31725 420115 113994 669367 384793 151935 75017 844805 784315 179689 477197 790292 565370 887193 242217 915290 840559 901009 590668 971942 403923 24416 706350 365882 931778 792532 909909 36231 609099 340714 486874 580103 136147 536263 317575 414540 707620 245808 159602 377572 352734 148190 325375 980432 398883 187115 567011 857489 876781 542757
Output: 21

Constraints:

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

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