CT51660

Rekha's Roving Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the river town of Willowford opens only for a perfect tally of ribbons. Rekha 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 <= 3415; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 317 83877504 667046 344614 741946 400922 76820 39051 198566 393841 143857 738446 426186 527498 796076 841780 956754 733629 346498 603990 732269 435926 200771 214356 60250 716099 412955 199707 586094 221130 390811 123320 290293 426783 722399 729559 943400 585145 996408 303907 716764 788838 588152 225401 232833 153682 839878 43275 423532 90082 444265 833812 219116 479830 935059 837311 219604 963396 802014 198869 110117 708443 328332 953226 110733 307260 103101 254667 603118 921056 610153 489898 828060 164293 789255 948372 775996 953085 2004 676988 220384 549617 317997 762100 559075 789267 977830 416305 472118 717835 47554 762717 827562 437060 946507 757091 254156 733584 297552 635966 992702 65564 601151 651725 597518 282172 984535 896457 154733 425057 3268 508805 911502 772170 201267 599503 …
Output: 163

Example 2:

Input: 2119 881293054 680360 419177 580511 710646 586699 391588 946860 441871 73184 77868 623904 978803 222550 980326 315011 59879 658483 906416 951066 344130 146288 545205 321567 432525 743623 358814 671609 692669 437707 257730 908645 789621 467086 836000 801192 922767 951351 351931 209961 814420 931364 969809 983441 76808 30387 598074 529720 779397 32453 781364 794148 444333 48775 975837 883715 397074 464078 976282 406371 453977 583508 620754 953066 165718 715803 766114 604511 998419 5863 306279 111572 807063 297477 951225 934800 470782 424241 584488 534127 543191 302973 635378 729122 253468 810627 270931 303966 407127 412457 951955 934675 113498 939634 527913 351430 990730 358188 988821 450486 366393 545535 135209 505770 45145 641711 928880 178670 405214 140446 826259 808666 955577 198060 3828…
Output: 1688

Example 3:

Input: 311 33054143 463605 199709 982021 545530 674319 669753 223691 386450 641081 67905 907462 766584 73477 727410 406890 736125 189157 494431 697752 355908 357254 254030 201166 346162 417403 721254 957178 287854 606632 29461 983867 619462 987118 836614 653022 425131 805166 966021 799587 731666 388793 89590 868107 47841 349993 391334 496877 769477 155468 617217 784301 367511 374862 417715 62814 653274 9989 377871 90598 631002 786343 154084 130748 639674 301854 613086 989042 673924 642285 688213 430854 578560 592152 600441 874889 352457 256111 366958 346526 360967 570610 903268 853605 746873 173694 197813 841392 352500 539568 498560 171390 970283 854632 785530 680413 181122 392889 538529 2553 903765 26233 58835 613436 583557 789081 449939 111800 945603 842508 260005 591548 78727 605959 133333 554…
Output: 56

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Rekha's Roving Ledger - MEDIUM Coding Problem | CodeTikki