CT52343

The panels at Tidewater

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the coastal hub of Tidewater pays by the answer, and Zara intends to earn it. First: the full register of panels. 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 <= 3731; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 65 20144 849 749 750 161 895 980 799 419 739 471 345 690 300 884 170 698 149 413 609 973 471 491 926 223 412 189 637 518 243 464 445 810 445 609 292 780 596 245 99 786 843 498 934 234 299 232 247 846 941 884 25 96 115 220 763 457 58 527 925 288 469 230 519 769 741
Output: 37

Example 2:

Input: 443 3982 109 70 992 76 11 256 399 484 381 393 312 454 227 118 138 57 686 836 618 532 199 35 37 998 671 680 892 733 681 628 443 732 34 966 684 350 226 113 187 241 513 586 865 884 45 476 129 724 779 133 492 760 216 14 963 969 138 620 239 439 38 454 596 168 210 860 384 347 569 842 523 104 986 416 848 249 639 758 180 176 363 65 609 682 874 660 195 726 686 323 98 718 537 239 178 759 967 993 300 56 129 992 493 974 120 368 926 612 845 434 136 910 703 322 219 312 127 524 523 149 757 241 376 221 619 580 388 976 542 367 606 991 821 525 244 739 736 109 136 302 176 352 252 131 127 438 363 99 980 839 851 260 934 14 158 437 474 902 394 10 682 70 778 450 59 709 955 78 871 529 828 677 415 564 783 955 86 203 973 335 456 355 651 482 571 435 474 373 227 92 891 390 991 283 399 577 682 641 540 744 265 777 277 …
Output: 6

Example 3:

Input: 1549 609654 42 586 472 928 670 742 538 655 618 645 201 515 763 724 677 332 23 799 517 753 514 945 326 963 247 510 986 896 429 960 373 469 379 639 744 754 424 409 831 777 456 165 227 422 201 833 543 437 839 29 305 536 967 161 829 447 181 781 996 815 130 301 291 109 569 924 278 716 859 577 510 245 10 161 539 873 490 284 489 237 859 460 819 799 631 411 293 623 211 373 220 121 583 747 980 21 596 773 921 513 326 210 857 957 727 834 171 151 528 703 297 377 900 580 832 904 230 658 385 438 166 610 819 734 303 632 69 2 202 511 318 68 313 637 586 942 87 46 918 764 772 379 190 432 227 48 157 1 980 196 342 67 127 834 65 475 182 138 314 254 642 707 127 426 963 265 554 296 333 481 218 189 975 776 533 544 516 917 307 722 752 728 7 71 88 178 968 25 265 948 566 627 992 439 470 836 374 506 928 77 820 343 28…
Output: 1213

Constraints:

1 <= n <= 3731; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Loading...
Test Cases:No test cases
No test cases available.
The panels at Tidewater - MEDIUM Coding Problem | CodeTikki