CT52302

Varun's segments Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the lakeside town of Mirrormere close for winter, Varun must finish the segments ledger - one figure at a time. 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 <= 1039; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 479 239066 740 263 949 765 940 32 990 565 679 775 816 311 682 441 212 205 783 16 653 114 346 486 155 812 531 23 106 51 423 29 220 892 824 15 593 719 167 940 183 368 172 959 301 139 898 662 586 71 304 917 126 938 263 859 42 588 785 225 944 435 434 359 831 220 65 681 864 245 633 451 700 112 316 936 275 201 319 585 425 111 164 192 909 497 330 676 643 798 595 997 905 154 773 592 468 740 222 308 943 566 486 100 560 455 951 690 593 228 930 119 649 667 653 130 423 885 909 435 523 849 831 208 818 580 705 931 791 822 742 584 589 280 940 699 514 311 511 449 857 33 978 959 334 816 517 571 684 456 637 260 717 958 607 756 183 43 529 1000 572 283 215 407 892 726 208 539 542 744 828 450 272 411 296 190 84 761 596 245 292 620 436 652 412 796 879 476 280 690 757 672 700 171 926 65 21 43 585 821 541 770 566…
Output: 473

Example 2:

Input: 688 179122 515 259 513 543 513 841 337 397 224 456 911 867 525 461 830 578 817 907 193 268 255 84 563 280 235 395 336 504 61 106 488 568 139 405 134 866 502 306 45 93 165 825 798 393 678 658 697 253 888 260 923 609 949 895 898 408 120 93 503 106 254 701 778 408 980 234 456 425 180 307 879 784 838 155 156 11 495 926 631 601 734 882 313 272 983 917 621 768 354 699 896 715 5 787 631 857 705 915 257 10 3 328 527 723 424 561 479 268 710 662 501 793 334 586 118 928 491 784 299 160 230 755 323 60 525 869 654 135 795 769 24 257 448 936 8 168 671 18 132 578 365 237 940 436 501 591 605 797 819 435 994 275 735 130 871 458 359 483 173 699 242 819 736 308 973 853 405 411 545 764 146 465 391 798 28 694 282 651 228 224 140 814 289 74 565 860 181 689 831 272 671 494 950 935 143 491 858 71 801 31 399 579 4…
Output: 348

Example 3:

Input: 637 98133 790 194 709 507 7 31 424 534 599 46 787 720 807 285 69 539 83 949 78 410 253 295 459 662 185 660 759 465 309 778 898 64 415 438 532 494 624 606 740 793 743 407 527 222 13 363 17 238 83 780 439 7 247 158 874 711 22 822 477 972 23 67 760 424 767 209 769 985 665 507 915 821 627 778 449 119 93 696 678 908 932 714 468 953 140 995 1000 325 920 308 594 505 590 580 143 800 174 767 32 979 486 480 412 356 887 702 298 210 678 370 442 531 59 831 578 702 819 438 393 60 87 864 271 411 25 793 551 739 870 166 185 304 425 725 462 324 775 933 268 425 540 967 766 903 294 156 187 359 502 382 346 97 620 592 626 828 697 675 70 971 190 109 970 515 215 670 207 386 351 104 438 536 245 658 679 707 677 622 352 850 710 741 864 527 596 317 673 700 58 803 836 485 712 940 818 449 867 590 584 544 696 755 53 629…
Output: 184

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Varun's segments Reckoning - MEDIUM Coding Problem | CodeTikki