CT55963

The Petalbrook Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the garden city of Petalbrook as Quinn unrolls the day's manifest of windows. The tally will decide the next shipment. 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 <= 1181; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 285 101236472 153434 706372 246888 319970 623978 217761 857729 876624 746716 587689 907478 829373 418175 30874 266460 917099 557869 690692 548514 372027 628412 569824 402856 418034 626173 22941 688343 448390 351871 284191 501129 256969 694586 829708 271407 499244 937752 851268 769494 740098 614618 180503 243769 285810 580523 733986 451541 997232 776162 844884 279420 246178 318832 775501 312572 371987 826490 811114 934147 566966 260586 338725 975440 693193 79613 713569 664208 625905 377764 382284 724385 430234 159156 885466 856411 131843 37499 713829 910739 424234 931743 388581 400193 115318 107202 512197 886699 524508 409962 913690 844186 264376 483261 313655 791855 37866 997816 589240 313329 494423 655388 744287 193740 436326 984897 252292 621524 551662 43857 423644 278923 432698 221743 4…
Output: 195

Example 2:

Input: 136 51944422 934885 171855 123693 333176 111974 958744 963168 926042 731437 992797 849253 567049 447490 719564 913935 229542 816231 858573 184472 739482 659786 580407 608209 979249 896920 372571 377272 883035 322678 518295 503620 50950 434533 814644 298326 612 964662 587654 242524 959984 540657 856456 735318 325833 111412 125166 346082 879949 288485 33056 941839 178976 785228 349608 474631 981235 871072 475812 566211 756297 334753 696923 399840 910439 224237 258849 266852 33503 914644 674514 573034 165848 311055 799176 578314 966521 518174 68382 789314 413791 585713 977829 28531 499191 754119 160091 56619 544558 844991 846100 600791 720029 627783 409536 200153 643586 883845 792656 563562 586252 184159 109775 216285 942952 627392 583596 60785 62509 51294 708726 996352 896935 940091 922757 8…
Output: 93

Example 3:

Input: 782 116822123 398934 682649 902179 896756 356244 536984 376926 294767 493840 391835 291967 623131 738008 333261 63219 875805 755188 746115 603723 45613 981649 661951 62738 227171 272417 173135 257524 300868 888886 910153 205867 951152 868259 956855 256915 822257 959887 471319 816523 945382 102310 419215 707635 823709 61866 181980 168858 888697 319203 799968 701726 245963 794587 658607 688575 982420 67784 504405 542324 718962 215977 872858 610335 272042 591524 559434 84845 974200 327931 992097 100498 258264 666767 617312 399391 312147 301705 334364 226857 124730 457455 593786 706394 299864 134185 451005 759135 563748 538957 676648 285271 74752 521131 742369 921970 270385 266483 597191 968109 703107 454869 446601 517003 458137 768303 285591 449907 662378 503109 610136 125158 753789 773700 31…
Output: 225

Constraints:

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

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