CT51944

Iris's Ruby panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the rookery of Crowhaven pays by the answer, and Iris intends to earn it. First: the full register of panels. 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 <= 2789; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 2158 575658 548 548 464 599 239 863 389 226 58 819 394 958 856 289 910 476 609 501 672 559 958 363 726 595 931 176 993 563 330 44 297 287 554 47 61 620 186 25 639 674 145 863 385 466 362 481 744 826 594 617 548 272 934 511 303 926 631 204 767 664 678 569 858 450 735 334 10 597 650 145 877 413 664 754 839 329 882 592 636 703 109 490 662 83 355 943 283 431 252 366 603 689 575 169 409 717 292 224 709 184 792 455 811 547 472 116 470 808 769 391 692 24 733 290 813 393 762 307 419 771 759 7 713 704 786 831 101 336 192 748 399 561 480 256 269 905 909 404 73 294 156 984 175 553 518 264 26 566 539 400 697 867 921 59 950 83 337 315 759 754 939 673 274 982 636 832 501 728 139 500 651 791 374 576 878 150 894 652 268 350 999 590 392 523 928 760 418 396 285 428 908 849 424 249 789 946 867 835 924 868 54…
Output: 1098

Example 2:

Input: 934 18025 142 456 632 176 985 799 478 197 715 602 403 783 173 638 18 922 992 950 428 578 208 688 417 41 82 457 982 752 312 838 352 856 75 896 302 922 975 731 724 157 725 882 165 214 935 949 71 482 185 172 575 821 982 440 905 317 641 366 156 306 937 999 668 423 164 638 811 302 284 82 238 360 405 271 944 295 422 756 323 935 106 608 239 178 252 373 81 822 944 188 554 200 996 239 671 345 290 448 229 243 707 590 390 705 389 818 51 340 45 205 840 747 125 270 360 248 107 339 744 946 650 13 531 278 633 851 300 849 678 189 887 569 27 885 85 464 160 766 299 893 616 324 482 62 5 550 407 849 891 785 590 812 958 495 555 618 765 907 976 514 450 252 104 244 739 93 406 777 921 759 794 458 392 766 186 943 552 545 885 29 266 908 91 122 396 124 140 561 227 317 32 988 635 549 779 598 996 81 305 221 423 311 11…
Output: 28

Example 3:

Input: 1821 898551 898 696 775 981 856 384 568 201 157 55 996 157 429 277 429 515 190 255 594 512 15 830 250 738 7 609 716 798 992 584 293 818 9 624 606 481 931 831 26 389 128 33 924 752 723 313 860 623 184 616 327 364 722 190 137 93 29 474 122 521 767 35 489 279 189 834 222 642 414 777 855 186 223 948 354 527 213 203 676 604 642 319 80 321 494 45 400 277 742 115 299 940 559 430 397 736 769 875 960 407 52 771 792 139 453 732 102 919 738 850 95 522 768 973 215 502 795 270 195 801 44 685 81 988 903 419 492 424 979 100 297 145 629 142 480 329 108 584 454 178 255 413 38 718 694 210 188 347 886 520 542 231 593 977 357 298 778 136 261 283 143 89 48 930 53 56 513 820 600 866 537 247 996 373 618 778 430 520 866 542 605 360 474 570 260 568 757 14 16 501 792 92 321 706 359 451 124 146 23 829 333 35 837 665…
Output: 1797

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Iris's Ruby panels - MEDIUM Coding Problem | CodeTikki