CT44219

Rhys and the Sunlit stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the rook towers of Chessfield as Rhys 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 <= 3732; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1187 486222228 148879 750814 463441 909100 104173 766427 999227 71842 924145 764156 278278 710940 645151 115456 190813 397044 487856 160968 389754 417626 866390 364310 57804 56208 123354 821041 583206 223817 701248 39764 19449 636180 716226 33200 416870 149427 453626 216099 173710 114165 863018 509690 205779 699849 633205 102647 106024 619955 44511 92363 141185 319575 603079 33139 130979 727299 67454 844402 306660 48138 56399 217621 68358 748094 531792 422740 334196 366029 98703 454008 895218 602865 416839 450913 490052 513669 906771 808314 246948 862607 141758 190052 135336 648035 745625 15467 770265 572407 716650 771383 480176 270182 572799 244671 791309 569013 945717 508396 642210 231292 750091 419173 501279 401952 120217 554179 167797 58569 31476 304913 310692 966211 703022 451647 4337…
Output: 970

Example 2:

Input: 561 141439839 107844 691081 872517 495225 512497 838000 584617 706044 752905 19725 24615 192833 399644 219637 23777 303039 965055 146181 202812 264319 23061 264879 302762 223615 793053 650141 315846 981210 849601 424301 552734 154376 385330 538858 298064 601390 713338 851411 21461 600840 51627 577892 901985 327221 964925 905992 289683 534070 818699 767572 250531 944995 390648 740874 438496 313725 833249 723438 322788 59668 478891 271210 149137 135170 491599 387924 579424 5451 175065 394100 987789 878158 610518 247858 172537 419135 699885 953869 574874 440031 322327 369971 438653 132973 460825 539826 913661 847441 612069 724331 219037 202598 991809 113513 104475 156143 863084 988599 516044 84682 727784 943116 259268 516420 577794 482987 937561 359910 136378 50574 769986 588954 193086 565204…
Output: 267

Example 3:

Input: 281 113280871 604365 251356 666981 534031 698118 651697 228302 745738 680374 539265 557138 891717 873045 265567 963046 229069 563307 15520 931012 188762 276211 319462 125404 306563 542144 60211 235922 483242 710230 727065 974909 834126 128325 282320 562514 298088 404460 966404 248376 119998 677452 456070 358279 462219 586163 819222 111874 436404 462831 758120 971666 554789 811336 115945 685145 878869 683271 530054 198365 600075 146900 439867 947547 106411 116978 337061 431620 756906 863079 589520 618805 142884 112853 235362 238482 927182 414887 642617 464753 349480 335837 170872 435725 202319 818371 74965 144183 958516 297846 290624 181356 214751 31291 152315 696491 133685 956699 257867 462309 723694 349265 826779 164557 522774 450179 735472 203538 75562 99708 446724 224463 347399 853837 7…
Output: 232

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Rhys and the Sunlit stretches - MEDIUM Coding Problem | CodeTikki