CT42875

Eklavya's panels Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Eklavya the scribe watches over the obsidian flows of Blackglass's stores of panels. A careful computation stands between order and chaos. 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 <= 1313; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 471 13059 820 191 235 403 560 247 93 268 710 3 522 687 304 810 140 899 654 808 152 494 181 702 7 184 938 452 725 135 448 141 290 859 354 593 672 418 482 261 357 378 436 532 375 542 548 246 249 619 954 15 884 89 65 440 161 633 480 984 272 123 340 489 504 434 301 113 123 25 843 452 147 265 330 442 723 312 720 669 282 156 152 589 205 876 254 638 885 109 634 771 240 607 728 451 796 445 712 136 662 652 662 105 377 866 320 597 789 987 953 76 49 162 664 266 472 430 747 73 689 779 245 688 892 981 668 737 733 888 30 595 929 148 50 140 658 654 96 766 450 144 965 739 160 579 593 412 929 730 448 708 172 794 784 477 266 846 320 801 226 749 326 329 324 422 142 123 51 697 775 108 108 290 518 528 877 665 648 429 197 353 966 29 40 151 233 829 274 652 545 683 60 642 389 500 223 568 689 206 190 809 553 41 86…
Output: 21

Example 2:

Input: 893 192243 137 844 1000 978 626 375 254 700 864 279 12 769 212 472 459 277 260 858 760 710 113 725 286 776 144 728 868 951 283 892 342 131 951 470 64 462 640 479 281 23 943 775 760 930 838 141 730 352 537 910 812 833 400 906 457 184 72 399 663 973 921 513 161 459 348 584 702 767 197 223 356 474 647 938 144 808 107 965 673 499 218 514 329 231 940 920 151 494 158 304 627 735 374 689 349 811 461 417 973 321 159 67 512 83 347 225 553 916 894 709 618 67 635 551 199 94 752 924 953 568 270 49 748 335 709 965 687 401 202 391 724 811 790 764 790 837 519 197 259 121 557 735 756 789 764 681 537 823 41 215 214 520 593 171 949 455 612 190 110 592 480 814 145 199 245 423 955 897 820 305 186 188 255 536 652 160 289 295 457 220 932 902 696 118 341 350 304 669 967 409 55 486 473 261 56 947 500 952 85 116 8…
Output: 376

Example 3:

Input: 1045 335167 47 750 489 538 682 129 975 126 334 518 650 754 733 192 948 971 933 786 154 799 389 783 922 358 899 710 948 637 870 154 154 41 49 933 53 189 923 499 923 649 898 230 504 161 755 37 636 248 29 542 576 63 4 211 873 841 401 819 67 363 740 491 213 214 666 205 443 946 175 147 81 96 311 79 189 629 701 608 85 846 279 866 800 482 936 748 830 610 742 945 149 776 49 376 155 799 870 292 651 753 791 929 58 130 780 565 38 671 204 712 109 891 805 937 780 889 784 494 65 595 889 103 916 643 788 998 995 487 259 357 306 769 978 5 697 897 240 642 339 539 914 87 170 109 829 575 492 980 387 910 565 178 536 238 184 220 572 984 604 603 162 799 253 249 994 854 740 923 437 296 836 697 140 130 542 686 486 693 68 351 203 869 573 873 7 275 769 885 150 731 860 746 991 177 893 828 403 625 61 451 42 994 210 95…
Output: 657

Constraints:

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

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