CT55063

Last ribbons of Ranger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the ember mines of Cindercrag as Ranger unrolls the day's manifest of ribbons. 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 <= 2242; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 2008 574215126 369683 37852 819206 930943 985807 638969 130702 783985 858473 569531 11589 771354 559683 743562 619244 961716 568426 585569 705671 264387 381285 66903 81876 981496 203204 249625 426779 132098 592525 655778 583641 531416 847641 555570 955102 247902 368178 844921 484443 459211 243908 454024 593400 143531 182620 404597 246183 857994 262115 25099 573664 174601 57560 425391 464587 782529 328887 890427 797386 165670 150060 699650 572690 175618 852253 779233 347810 919103 634956 498902 147937 281272 993521 454164 102793 853590 161798 642141 865011 572942 261520 300858 204613 244288 832987 534095 469723 220179 278475 654677 257259 195223 495109 49758 526864 820028 378934 65030 658241 818572 163174 999886 112541 754778 156794 938406 998843 354344 884836 710971 72168 460558 571252 307…
Output: 1126

Example 2:

Input: 1010 412788007 443074 868189 172419 292573 826816 859143 560319 788793 293505 209213 579662 60534 930573 692742 128871 876030 388038 909310 738737 520157 176715 482680 919938 396578 736593 780197 528242 750813 287055 736362 599777 665660 68488 188230 751573 925435 561575 415089 130295 124082 350508 932450 540662 215786 690027 533106 264129 296397 106471 203345 162804 114895 382903 414611 659302 848966 408116 887550 449573 918162 361750 131884 531444 972438 625834 420703 186204 143289 741241 835849 579349 744226 116364 7952 429853 499328 820799 204708 634978 411024 733049 322550 743258 119495 558517 794793 866590 191827 54670 237824 85539 159058 579056 772900 34623 13531 175346 242435 235314 545741 726138 85859 51348 758453 4476 842460 830973 429194 932912 336180 6524 551425 399912 514109 2…
Output: 846

Example 3:

Input: 850 169307515 185228 703752 792289 774750 506826 108909 726527 495047 376125 90772 126039 479344 300305 432543 319928 464523 384740 426137 709179 814257 347126 727213 482908 686150 653972 344699 74374 689703 303432 675688 232396 828996 235320 796582 764072 951354 711866 670757 558177 604944 588663 317112 69897 829995 609168 645453 53512 654415 710251 863210 940448 23998 28408 125629 289470 677167 83907 94158 1247 955901 808709 201706 991431 181872 632792 262991 857900 826079 770294 495130 11695 445244 975423 969155 969922 946571 333127 134075 710998 987242 258135 698175 614548 655679 529305 452680 739589 373150 215454 717067 703952 848769 653332 112589 59012 531540 81300 760601 701985 243652 111952 518296 444570 184210 863499 603125 213876 874171 166501 757962 605861 304941 5492 655181 901…
Output: 335

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last ribbons of Ranger - MEDIUM Coding Problem | CodeTikki