CT43521

Pia and the Hidden panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the coral atoll of Pearldeep as Pia unrolls the day's manifest of panels. 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 <= 2772; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 1847 169982898254 562763680 214087319 589014477 386059162 208042032 394066846 477239144 74537797 595111485 607940284 871927559 950912341 187849271 313683635 556298825 803938229 18802003 431790183 575713074 578955434 170075525 285604739 830986288 93119158 278773225 231133628 804131930 228615901 610129313 555480196 292306261 533236328 81182805 134043159 608093338 264026334 325932164 644649538 780679002 488608902 785697481 246573765 958018119 358645670 676335200 637084300 831719120 603265398 807874745 978712140 369111064 631707210 804537223 276916351 578788774 499794757 251957181 994464807 333696031 283196550 320750122 938547641 354624891 268811467 329498122 566065282 493737093 247676830 428461914 484022575 584192891 46219274 97960171 299643238 300527161 503575751 156838943 777594194 84316632…
Output: 327

Example 2:

Input: 897 309528348601 306049827 450236305 662284834 86765016 546247882 665871141 21443 733682597 848971411 588014657 145885954 326505364 702838441 750378984 63083311 915721247 186887917 189159308 22941412 730300992 249103498 722596224 501347073 81111043 512146915 692966222 4691155 629722375 458958893 71441530 960160246 112216675 412505146 493479904 196891362 615441948 612578750 269308562 823982308 624033302 959515841 819732692 205372126 271447462 1098221 482661263 336798288 295780740 23662175 340727594 490162574 719214076 698317635 533702914 313417599 440270394 910301437 432634509 944957989 286980423 814800677 704205704 436418342 303211127 558133638 547556199 396383490 726552439 51746554 797066868 61642841 724413657 814426517 455136205 254317510 52153571 910058591 105847355 591710880 103815145 …
Output: 630

Example 3:

Input: 325 90206162580 726065255 906571128 876792711 7569926 634173963 16777137 630169644 117325628 639856829 437434097 914319341 529553471 78911035 60211613 13699952 984168078 625058869 806148357 507104755 208724635 555281277 967185802 526408659 83767742 412287879 753145688 796260522 54140823 156497578 130518242 171976849 42734791 311463746 798057102 861577415 319893517 611316218 52858323 21173396 67553678 847067712 40298518 87891052 905210247 886037875 368842912 944434692 726646883 457581191 100361217 953477487 48939311 30785676 632039691 329872426 514316444 386051696 544460304 279103090 957056112 621562505 904600916 61251579 490224915 85517760 387547741 284284730 50464929 601284322 533379975 961426178 694631153 453671476 973458600 364660942 736302763 437885221 552458604 309571250 63667124 5897…
Output: 173

Constraints:

1 <= n <= 2772; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Loading...
Test Cases:No test cases
No test cases available.
Pia and the Hidden panels - MEDIUM Coding Problem | CodeTikki