CT46146

Honeyed segments Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the thorn maze of Bramblecourt, Jessa studies rows of segments entries. One clean number will settle the guild's oldest argument. 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 <= 3281; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 938 341411565 407057 307633 847208 997071 683523 695472 291831 202189 20618 320614 604042 251242 31832 818318 840796 762170 635695 228533 445342 60990 626214 355686 549860 971116 947644 551005 764273 565828 128454 619934 871188 11743 296394 160086 871411 529817 638074 494952 674638 963889 93202 380870 118035 256198 967714 331433 957039 781512 565619 209868 678947 939701 240778 793697 320330 161624 66730 249872 571298 434240 580901 742692 745765 700822 599465 755893 121714 606306 372657 168045 409217 576906 9079 137934 982097 357119 12524 440964 612777 230592 313988 383058 816497 925088 279849 812164 85669 338253 649324 482672 521452 460156 764789 905750 780861 971921 8352 677478 990767 88546 550057 783946 886603 416986 560154 261664 490267 790031 525227 890564 354430 95671 325380 150934 69…
Output: 647

Example 2:

Input: 575 81356314 108452 874141 305109 44345 530117 825535 371104 355343 990882 957308 971414 942368 990917 385434 775107 713362 477415 913168 75308 708223 919293 664724 47089 500870 125602 376996 523354 350270 80023 787483 243310 74414 442716 525826 434923 879011 742896 219655 563281 638815 497811 581095 869458 372294 423612 505983 639763 688879 314687 205250 987647 982594 267882 877771 380446 980220 55418 155668 40775 387196 192498 651043 922391 593608 223055 892583 755709 579240 834821 969634 32623 493365 452897 756590 924512 639434 614464 883619 690884 766010 915232 298832 737820 706912 542279 571150 41340 728991 454966 609008 749289 439973 564449 769002 835432 157294 129272 101101 530344 724668 857007 549893 286549 487698 979581 466430 386411 164304 198588 216560 526980 965549 852585 81059…
Output: 147

Example 3:

Input: 339 74121566 923334 341588 672348 777034 724026 786278 181555 677091 674655 426870 79208 420767 987680 273565 283691 861574 356547 445728 651128 573550 388515 917212 556408 555558 807625 976834 460073 341435 43962 513937 708744 277843 698631 470673 271550 360056 961164 553432 702819 617696 921398 588224 577052 425988 253878 246236 833789 579394 805367 595444 516667 690038 521698 941597 273514 416316 892144 171567 352446 949248 392600 836810 725127 700159 417214 408323 82202 483500 140839 489783 787331 177301 816464 644694 421836 15942 31822 394217 705104 897443 412820 97983 1605 781119 270409 744803 801203 15824 319528 526192 62084 606153 635169 959885 967259 317239 289937 154846 348825 16430 221345 613387 46428 235414 756531 489683 831067 27458 232525 202105 296466 284290 609669 144606 52…
Output: 140

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.