CT49816

Last scrolls of Notary

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the trading post of Goldmeadow opens only for a perfect tally of scrolls. Notary means to find out. 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 <= 1056; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 913 387352 591 796 772 405 864 95 371 920 654 183 946 893 607 223 286 294 979 435 181 169 1 529 509 854 915 295 215 525 537 607 222 231 597 527 648 261 546 683 211 303 228 606 784 602 871 979 122 621 111 442 451 899 456 913 121 502 489 953 348 379 94 647 814 902 273 177 478 43 747 81 411 473 850 185 617 550 113 455 591 378 473 131 671 991 356 97 690 600 89 58 874 446 911 758 780 552 684 352 620 896 693 572 954 143 181 202 134 673 885 877 408 143 59 176 191 573 308 787 516 727 812 577 608 441 966 797 587 625 553 169 726 885 382 255 463 440 193 201 147 150 639 849 604 424 75 562 582 153 41 106 564 187 358 714 417 147 779 537 323 197 841 271 980 811 226 875 665 313 25 772 135 899 62 777 140 250 53 553 319 761 26 321 293 585 347 273 666 114 307 87 541 788 866 677 332 341 828 442 961 809 792 19…
Output: 769

Example 2:

Input: 1000 274602 66 704 835 526 446 937 265 343 376 689 172 628 550 667 978 834 878 55 580 473 297 668 56 370 613 355 947 613 852 404 235 429 241 293 581 616 309 292 716 50 601 281 376 15 284 698 780 354 331 522 404 908 752 187 60 922 152 579 470 689 332 577 694 197 99 282 133 660 616 33 61 797 31 622 10 616 53 325 652 958 959 148 528 860 271 854 827 696 733 674 922 184 955 496 220 131 627 93 338 995 652 467 83 157 884 530 756 221 666 342 593 358 977 771 957 404 599 687 872 185 356 463 955 180 263 517 865 511 516 215 70 707 99 307 673 970 6 786 839 783 56 473 941 708 594 300 32 167 415 467 223 458 965 326 498 649 862 336 639 829 495 135 198 103 248 722 958 159 111 845 645 774 11 899 376 289 748 226 29 337 321 345 135 218 619 636 675 448 830 715 629 254 906 85 515 86 821 350 28 529 244 356 500 5…
Output: 542

Example 3:

Input: 234 84359 94 813 752 904 808 452 674 289 990 128 119 285 736 66 955 592 82 557 221 239 394 622 186 505 337 839 368 93 654 96 420 152 845 120 195 177 716 925 965 717 509 235 646 805 794 646 216 308 40 941 619 739 202 960 226 765 381 773 609 31 634 378 262 103 97 28 297 296 398 315 336 288 592 351 924 951 916 987 408 978 572 536 807 851 647 237 339 504 836 80 934 253 452 517 607 940 504 42 175 992 540 766 126 242 951 544 79 248 634 647 412 329 187 18 562 905 15 579 583 272 469 110 996 206 831 411 415 934 289 434 609 806 142 650 877 282 881 645 315 480 244 704 472 31 994 977 312 285 904 647 734 755 540 694 217 748 130 754 253 146 601 993 653 499 501 232 850 593 974 848 715 187 834 885 778 795 502 552 408 663 284 185 385 780 622 61 162 812 405 123 243 583 387 237 340 264 883 844 912 838 443 57…
Output: 153

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last scrolls of Notary - MEDIUM Coding Problem | CodeTikki