CT54537

The Whispering segments of Harish

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the indigo vats of Bluehollow with crates of segments, and Harish the chronicler must account for every last one. 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 <= 3585; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1043 137855442 375279 571373 980416 237606 391922 256816 918265 594536 669901 467150 92979 366876 491962 300330 471194 368940 485466 408803 644447 415398 870155 820758 96716 311354 15690 190585 171036 615052 879382 748883 732583 505823 370068 481669 588937 126407 874518 919524 75418 781289 312395 49952 698088 556669 544481 732236 851483 291168 588594 264336 378465 66355 417517 115358 587346 21144 865639 242646 997323 780628 596162 549404 795317 135663 215674 13746 82551 517547 154956 478069 140034 553721 429667 925386 466523 77779 676308 689505 58378 937441 480699 452961 442156 539050 575217 32213 747783 443034 196529 377906 471205 223754 489199 92160 399104 589351 450104 569782 661216 249434 388564 382274 667955 15798 148621 269978 412005 700674 396021 10247 293451 849478 271526 56135 119…
Output: 257

Example 2:

Input: 2999 109394698 283548 409522 52226 698860 469897 476945 746729 765689 616652 800973 22116 572667 851151 722978 560789 863826 977812 330112 454149 733850 561326 232247 337994 707928 58994 937278 853201 918881 12030 871242 359838 566765 838934 598620 752511 739702 288433 645054 174432 557882 367101 405704 225848 68034 529207 346687 57409 371051 251798 879573 312405 337030 416295 412004 691766 693098 56131 898621 757701 954895 651983 863355 633834 209997 439604 812362 323400 669542 593646 345053 28762 899074 929928 734814 472499 882544 603914 967691 234949 221350 198763 98906 573477 859442 129526 569458 10993 399823 788004 9275 678464 122418 918195 787020 989829 334776 305672 958378 239966 347604 791487 365867 328641 703224 403790 296924 525404 291397 936556 734211 214415 194199 322218 249631…
Output: 196

Example 3:

Input: 2501 211639236 982922 121457 136323 82681 308020 867181 666380 181179 744925 535422 916423 720568 866542 329931 662613 773928 914144 957940 634167 546705 248736 934398 309877 832357 30085 993406 71140 14707 480769 800865 19018 244863 396926 475974 869254 275850 670088 53630 332571 556718 622273 720692 308926 446014 631239 790324 286723 766193 490696 672488 310743 567381 153951 646459 855614 657818 470220 366295 434648 159888 870887 70435 880522 970026 321346 743823 656387 101811 424817 997541 701700 634849 814797 279509 388058 537045 41282 79761 994446 642347 910967 774079 885664 865062 945827 139241 655589 214955 243459 350847 658839 792318 359168 668594 864579 423756 351792 275195 738476 543982 360046 309526 973819 805617 212382 996343 139986 790354 424565 672086 86258 284945 947469 2862…
Output: 393

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Whispering segments of Harish - MEDIUM Coding Problem | CodeTikki