CT43255

The Tightest Stretch Beneath Amberfield

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the wheat plains of Amberfield close for winter, Notary must finish the panels 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 <= 3735; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 1321 170147 336 505 600 470 152 333 970 493 181 96 522 614 889 698 105 926 196 638 359 625 740 127 204 292 997 95 400 26 379 939 140 777 477 996 195 235 563 798 307 199 514 433 343 974 642 998 554 54 262 619 318 143 143 64 554 214 260 691 703 136 972 343 710 630 131 132 790 173 854 567 312 600 645 215 833 466 758 913 271 20 269 799 263 565 595 542 350 458 105 534 63 943 592 879 341 446 765 321 130 765 564 530 664 149 392 638 960 297 995 124 305 117 656 156 933 266 2 818 202 856 431 873 487 332 447 967 570 381 988 776 970 950 977 160 894 690 754 113 102 84 249 924 369 115 42 327 101 295 411 464 987 653 253 796 727 486 555 937 842 826 728 600 531 699 614 540 614 315 710 30 565 887 660 997 724 264 605 936 229 268 992 377 88 322 577 460 185 345 987 946 489 981 462 116 849 107 467 383 318 108 6…
Output: 321

Example 2:

Input: 1503 23557 951 719 4 294 717 640 732 499 354 793 236 124 453 941 69 871 866 413 317 344 762 535 903 309 442 62 369 797 683 361 127 132 345 665 592 389 618 922 278 169 455 204 824 620 721 839 997 943 842 944 544 13 842 28 373 185 293 627 647 508 879 113 64 538 844 529 357 96 367 622 781 184 718 417 934 819 683 786 339 978 704 435 559 332 658 508 331 589 534 942 402 96 422 827 314 894 813 476 33 970 87 503 247 212 61 822 145 851 963 627 42 165 811 256 119 225 887 77 608 633 824 336 934 517 673 784 853 836 217 208 721 294 835 291 990 270 549 861 883 292 828 847 934 431 489 902 208 739 579 348 939 189 264 62 433 790 17 501 101 47 945 876 908 518 851 472 602 550 842 316 959 238 219 311 666 619 27 622 820 673 495 254 522 95 198 680 517 297 645 915 549 732 493 559 400 797 60 282 299 280 916 508 5…
Output: 35

Example 3:

Input: 3719 1799044 231 446 746 303 371 552 144 294 50 739 641 774 168 672 955 928 46 708 59 944 869 435 161 470 51 183 937 496 30 444 573 170 416 194 373 993 235 864 616 345 439 197 948 405 707 723 997 657 268 524 98 588 298 879 266 295 610 133 247 692 457 115 700 369 583 173 881 732 663 116 675 520 111 819 485 306 210 756 198 317 835 205 453 701 705 607 415 478 717 296 693 173 276 55 2 990 583 715 176 409 261 708 17 387 810 486 298 342 412 890 365 321 554 727 869 77 798 760 169 738 150 172 636 545 982 803 764 237 554 39 711 174 509 482 550 133 826 876 270 113 1000 135 863 161 923 230 618 304 2 311 825 658 689 990 381 579 631 984 512 329 943 26 586 580 705 468 50 37 788 57 742 956 577 982 760 188 498 791 281 160 239 218 2 247 648 543 937 160 810 930 290 260 443 950 466 226 390 806 897 481 149 55…
Output: 3535

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Tightest Stretch Beneath Amberfield - MEDIUM Coding Problem | CodeTikki