CT38429

Wheelwright's Ledger of stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the bamboo terraces of Verdantstep, someone must track the breeding season. This year the task falls to Wheelwright, armed only with the stretches register. 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 <= 2132; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1396 185139163 733268 343475 658366 175756 907898 59603 586996 146178 371966 775684 533469 11160 205083 431414 130148 145435 459660 35833 460986 842208 496768 765974 544037 32537 349492 716138 131842 198313 184017 774054 848204 172932 972388 980758 315609 572969 944225 965403 754877 769417 510253 175472 814385 901384 674747 156424 619116 48026 976344 651416 315352 222870 880965 513306 879303 541563 767423 842185 522608 208817 749828 932402 643146 826657 708321 605013 704629 558446 893795 635601 532391 981637 199017 777336 579267 27351 540637 697462 486250 975668 639092 2079 690661 628470 800138 3898 87907 805905 803846 701771 279989 842429 168142 261487 701910 764065 239710 298206 952764 220608 595471 961891 969089 546944 744813 802220 149545 471959 751848 336610 784593 806693 789322 17190…
Output: 344

Example 2:

Input: 1312 361131805 621814 126087 692200 821916 554607 604831 664740 322715 4553 363563 855669 347692 369160 802287 79799 133674 150041 132167 589353 407190 831825 218582 85892 523418 134999 688316 998060 184617 410601 472725 295396 139934 704266 834786 610024 85612 770931 776692 686961 83120 38779 404096 218217 176779 321310 961664 949167 876298 482102 101764 74307 285094 451272 573964 158024 467316 202481 918386 660719 421557 130562 589937 208900 796993 534638 327654 791693 350698 908257 714037 736164 868578 364512 174865 880088 326562 611472 73076 965710 250472 978571 743994 777454 59615 994693 188438 783882 783562 456361 577600 511604 113039 724764 366048 972026 903165 425957 283103 421878 624466 344484 335212 658041 709053 479992 464175 879670 83090 31936 18370 310506 73242 618201 864537 8…
Output: 719

Example 3:

Input: 853 340121435 510166 646608 727677 62610 962871 441718 185039 343851 429591 512076 131869 561716 844349 344302 581753 129946 457851 921107 537155 602415 552632 213327 75581 983404 891292 359421 854428 637343 389155 605970 951519 321586 279107 943820 952165 98375 52903 356208 52251 811016 984834 406031 417545 183366 326247 865027 185789 777278 568841 139858 3742 109524 827634 664965 673029 411122 487775 209257 940898 195336 394711 842540 895027 797884 151079 535285 309430 738344 842069 299965 438649 817892 758222 924484 464497 215165 997269 786025 949828 660849 267458 90807 816208 999164 377895 155010 368173 311234 828115 728676 790417 155382 663275 702704 91286 567647 192193 871214 154863 135823 373132 509428 876323 989318 973912 394730 638872 955532 967048 663156 311683 404785 433507 4861…
Output: 665

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Wheelwright's Ledger of stretches - MEDIUM Coding Problem | CodeTikki