CT44776

The Starlit stretches of Ravi

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the old quarter of Brasshaven as Ravi unrolls the day's manifest of stretches. 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 <= 3475; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 3412 895316247 630844 196309 559459 570476 611508 102164 203233 261235 931003 530430 498858 658573 998083 110226 234163 808440 556689 36577 571779 72893 307738 657470 785355 793169 693352 616168 271085 695041 245629 8238 356585 645509 438631 261791 339096 830934 678013 108363 363014 881403 885508 993953 204531 850273 490675 491342 575985 498731 246128 105864 369052 837023 802906 246811 344241 959549 201582 211745 944178 120510 247616 846586 490676 311177 807103 810940 127830 90697 321718 551843 578019 890498 637488 300831 640897 279051 459244 961759 196358 816343 165298 866953 876924 139556 412702 765103 639367 235500 194843 946722 774971 492838 621099 115504 152912 305153 461501 136710 442383 461012 257900 620361 511854 669734 820615 174256 510740 585701 188865 559289 800248 281009 634852…
Output: 1763

Example 2:

Input: 93 39215529 340263 758221 54601 54990 690505 532581 763598 493515 899482 713035 638342 707061 589448 619691 288935 717544 376030 62400 867725 231707 595844 470914 573219 860304 541659 898187 600091 599033 270906 144716 340285 150270 985011 752989 568887 147414 158710 642825 982822 598757 167176 433200 524709 921856 92432 45621 420005 849589 47342 92099 872444 74469 552453 158672 809579 934024 685654 530595 533926 720044 161037 334721 661067 924756 479024 144987 517472 782387 958399 904497 390919 919232 281283 479770 685118 79727 202880 847783 905943 33247 129352 492506 711850 531735 245033 328827 89725 504113 143293 36908 979561 198890 823442
Output: 74

Example 3:

Input: 1230 456749169 43725 374191 135772 77044 274747 100420 718259 415005 648611 883373 765953 64525 428219 32676 897249 343958 58261 223767 590399 150553 299385 903913 29949 681880 411843 192098 597811 820254 594238 891664 848464 468380 220591 672781 945202 515792 92807 223836 13445 137430 124490 345956 402076 736399 693342 455267 33089 809732 288816 588630 285971 905294 989249 968378 449402 822952 487488 915552 989039 709586 669842 536458 276080 636757 710986 209517 898169 360636 859960 346553 931692 412549 868583 896505 150578 108053 377941 692714 978640 981700 275642 565679 930184 689156 406263 630535 677823 500579 850633 708099 636749 299594 927627 31592 375689 80885 685475 796 76292 911154 15784 345676 66214 128421 129556 122308 83723 91514 407524 999853 146442 594988 153905 174128 812524…
Output: 910

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Starlit stretches of Ravi - MEDIUM Coding Problem | CodeTikki