CT50576

The Tightest Stretch of the Wayward segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Tanya the ledger master watches over the peat bogs of Mossgrieve's stores of segments. A careful computation stands between order and chaos. 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 <= 2550; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 792 211484331 824744 766887 883599 950951 526402 709240 319978 762967 823464 40810 854731 983800 442542 740115 683412 875272 562235 110721 456425 565448 388222 63372 4017 349629 174622 704158 352628 715485 754803 291919 284861 840013 440873 178975 346481 730098 978324 442368 667157 278888 991942 23303 563809 226086 98776 2369 319107 778320 180174 850747 330418 70158 742074 201845 56769 852518 619281 511588 834859 999494 546040 755726 679141 213563 395453 257711 309809 642777 450984 707574 870755 35486 548124 537063 67149 942354 633508 810594 254195 514328 841971 6683 824272 508969 244175 68076 673565 298821 711781 363450 682521 683258 313175 633735 508318 534343 610677 949773 626697 423371 756152 921366 452455 262620 807099 188752 958036 894978 430521 470102 864642 255551 318991 260876 411…
Output: 424

Example 2:

Input: 1011 38059682 943435 571652 43601 719842 360254 642516 532722 716798 706742 866147 829423 74087 793591 264817 799424 83137 97833 461355 710905 419774 322322 58879 269636 51295 135906 812406 887937 370809 806447 325423 803934 733179 911930 304328 241696 435450 510124 914450 764423 118497 109489 587101 851394 320316 865573 774179 647726 968145 118036 190678 505571 332836 94141 942183 89572 649680 750681 38867 391925 177684 563824 411230 489302 254236 713467 487543 875907 556420 632458 26650 825048 691561 832061 630539 381060 41609 80755 852000 183298 512550 357908 309246 899183 620942 50196 955884 474096 582043 975996 401072 266671 386768 934814 39814 22798 337249 234869 524524 941456 293359 537657 669680 150788 505867 327096 738713 807431 968719 5304 69483 111596 476586 329241 825362 674533…
Output: 66

Example 3:

Input: 124 45678364 590908 268379 922141 717847 150062 576093 391472 52140 253688 911564 712952 677193 7765 44308 304085 822257 606255 292665 340970 552881 929224 580173 299138 366227 483810 96050 430071 432708 717833 645065 864717 814721 91494 548321 321571 808086 424322 819983 667072 17315 100771 552861 289490 51979 901274 662548 310343 575252 700767 564534 656629 417001 999582 552348 792327 863307 857683 131544 933854 36597 103712 795675 289804 49477 418376 855496 319634 641835 927664 616005 590662 629039 487646 454938 962740 921867 231749 355543 445892 368240 110543 297650 262961 282481 313357 449382 67179 790833 908711 526362 637536 987530 797971 738572 746860 455821 775051 814901 679703 483120 413898 808700 96078 755765 857267 809177 340661 189495 659883 715011 785039 27230 812398 79731 806…
Output: 83

Constraints:

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

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