CT43267

The Tightest Stretch of Verdantstep

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the bamboo terraces of Verdantstep, Hestia studies rows of stretches 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 <= 1258; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 856 327754710 238321 248690 980998 875103 39745 703200 866206 90289 763158 198512 95471 831749 514555 786374 272691 878936 900687 739171 785991 729259 498989 145032 747802 877204 336931 471083 777873 440539 445819 860957 563596 127131 632919 318111 576196 16367 568793 202463 819546 368489 811627 319063 368738 315160 937385 819870 237220 747850 376322 865374 310194 930768 368403 249792 253872 587064 304560 781286 949644 847037 441206 369734 628510 442306 189265 195178 793305 411981 702070 563207 75052 733536 836630 788569 657333 419435 680638 920651 282912 575830 477012 21176 720507 834133 78905 819307 295791 353452 602422 699933 40269 469858 981999 636813 375957 530693 300778 534024 558681 439194 632805 182630 766383 126580 429675 468780 309299 858999 466625 519111 720911 550611 595353 916…
Output: 654

Example 2:

Input: 703 197074347 404801 576670 438379 468936 531643 357780 755020 275142 129749 524165 733274 833115 134980 52470 945758 512458 133088 364281 513435 407683 524166 904981 499502 110815 842073 883317 316957 838090 302494 637758 145456 904628 809547 753953 655753 341652 917856 409637 427800 180104 825270 103218 608521 326574 618919 740836 701771 310908 991381 695511 799694 245527 177548 351649 575036 801730 261369 663344 85839 193864 948198 516360 312326 930113 665341 510331 908940 837702 440769 162009 965256 868154 36876 744355 528060 92424 512119 290861 708019 189748 196722 262445 349425 288333 849965 462848 193353 830427 862221 929835 17439 871451 222552 829512 707748 957943 699417 627511 686207 645500 175829 286207 672220 930543 82419 434436 482563 623882 722804 971192 308783 947017 273619 4…
Output: 377

Example 3:

Input: 362 52581305 788991 161442 992520 570461 35409 594171 934992 482621 892915 69014 436188 514680 329627 442738 302882 201061 627259 769492 275580 933863 900276 571922 335907 276474 809499 376177 681992 926216 732845 421174 600951 297093 863323 279336 439582 518541 871967 340013 331071 647103 981063 415773 493472 87360 376068 640944 960950 143864 396729 677530 547784 529296 989213 954967 789268 724710 56602 179797 433234 661176 787494 778559 359729 287666 546162 932950 839048 506139 673628 413783 35241 685297 634478 226270 631921 836818 424415 239368 983956 353302 486894 108016 661118 198462 826927 337734 549072 32587 383037 835497 804149 818886 630374 66604 157352 986236 316120 122791 645341 199488 877293 512615 619790 153483 530074 423571 284322 122477 633254 405196 413633 361881 907140 624…
Output: 97

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Tightest Stretch of Verdantstep - MEDIUM Coding Problem | CodeTikki