CT52478

Rosa's Tightest Stretch Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The auditor Rosa has been asked to balance the workshop's books. On the desk lies a long table of segments readings. 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 <= 3196; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 1912 608215 667 21 541 506 90 255 4 805 526 474 519 17 445 483 643 148 923 833 373 235 304 485 645 685 817 893 499 183 134 599 535 941 884 704 70 536 207 970 635 996 731 412 708 803 890 293 675 785 499 969 24 334 786 585 854 248 588 319 281 783 11 889 606 825 630 964 818 929 974 842 509 958 68 323 820 492 596 39 128 123 406 502 749 979 496 165 440 165 39 381 453 626 969 425 309 772 451 60 506 347 704 346 680 737 870 50 218 266 685 435 61 972 452 41 742 475 514 9 548 512 362 852 920 574 26 433 895 855 536 52 390 162 506 126 328 922 900 933 28 10 24 416 201 502 7 153 341 684 643 563 580 589 3 693 452 411 551 279 596 676 941 277 34 931 127 519 4 816 472 223 287 535 355 640 10 978 603 859 84 16 699 515 924 502 900 57 250 209 251 358 258 112 808 955 884 885 977 932 601 881 439 690 441 557 316 3…
Output: 1193

Example 2:

Input: 3193 119657 844 73 142 445 112 537 710 2 760 320 183 56 409 207 533 341 621 998 466 513 740 956 94 551 806 875 592 847 979 379 23 19 602 15 133 289 155 932 49 319 123 79 355 46 718 582 207 210 415 380 327 458 558 952 579 796 940 624 665 142 714 609 462 266 281 435 760 694 495 473 91 299 269 869 835 384 256 286 550 59 706 935 168 307 64 660 942 848 213 149 963 200 328 540 409 352 428 846 200 773 634 947 795 175 329 543 405 515 801 705 449 266 537 773 267 219 398 108 524 523 196 216 155 248 547 103 120 905 89 315 815 279 396 54 197 331 630 755 940 783 789 86 539 398 32 162 400 532 691 629 453 950 359 348 833 52 829 363 611 493 698 708 642 213 745 367 807 414 605 772 496 433 9 826 921 467 10 971 190 417 234 338 769 304 362 212 401 416 256 253 965 709 893 878 336 60 196 25 807 510 884 641 335 …
Output: 222

Example 3:

Input: 2206 761104 559 359 112 350 152 264 866 946 313 423 916 743 535 127 925 59 284 549 727 505 850 774 189 492 870 848 223 171 357 679 691 662 650 965 613 446 171 581 644 716 73 964 827 13 56 554 727 489 545 76 716 612 977 5 100 167 45 371 123 761 544 995 643 745 135 797 424 240 706 29 870 393 436 264 203 77 857 738 464 342 21 960 128 577 109 622 472 495 150 711 910 365 577 127 348 955 399 614 615 185 743 146 473 787 550 832 957 125 933 973 858 488 65 222 578 244 322 691 188 752 543 271 502 630 4 373 890 107 910 378 198 484 122 327 727 940 890 397 770 140 41 363 842 823 568 27 887 299 709 177 197 895 350 504 380 232 178 939 187 845 150 179 925 238 795 495 911 772 920 542 935 697 221 589 887 807 387 59 852 644 604 914 604 51 599 705 551 765 433 95 629 800 884 156 922 468 870 282 803 481 17 46 7…
Output: 1530

Constraints:

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

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