CT56538

Last windows of Elsa

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the foggy moor of Greyfen pays by the answer, and Elsa intends to earn it. First: the full register of windows. 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 <= 2969; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 2226 1087673 591 616 289 708 244 896 118 622 466 514 605 836 17 301 558 317 607 609 919 100 39 595 720 357 846 166 558 717 860 856 810 33 65 64 207 456 257 949 781 766 233 461 51 709 133 172 191 839 909 180 15 55 132 540 71 575 554 450 569 469 438 403 724 358 693 522 207 250 102 245 460 640 629 958 229 424 397 782 636 713 249 346 815 663 8 43 476 302 789 951 223 391 113 997 720 706 625 17 971 32 986 167 362 833 995 484 824 483 40 172 567 733 84 272 298 528 831 937 114 766 691 414 123 917 87 962 614 89 178 683 21 891 410 642 794 46 681 33 854 166 689 262 640 138 197 549 948 165 271 934 170 872 879 300 136 499 207 141 417 778 967 35 549 935 53 511 243 19 550 329 881 941 294 704 35 561 387 747 792 362 494 463 487 973 118 561 975 756 492 26 60 814 419 509 546 1 59 53 146 151 763 683 380 791 45…
Output: 2219

Example 2:

Input: 1376 561330 982 507 167 961 785 996 231 170 988 897 475 210 650 683 563 870 754 233 961 732 397 686 121 72 127 354 125 42 248 951 97 51 848 78 309 763 347 977 926 541 757 625 507 522 431 745 888 798 602 448 558 859 151 388 278 732 472 357 300 467 861 554 561 146 217 705 159 836 37 597 13 40 903 960 183 461 471 737 125 495 144 321 37 646 814 794 583 463 716 209 157 243 352 665 463 200 125 947 593 442 658 764 884 102 805 561 110 831 688 18 345 936 10 778 955 566 252 717 522 840 361 338 733 831 712 549 753 703 475 322 605 242 337 423 889 698 422 295 829 137 857 249 491 943 243 883 498 2 377 97 817 256 683 85 302 163 942 675 558 871 935 95 20 172 641 363 252 888 579 847 473 818 82 73 502 327 515 601 240 759 445 595 269 759 451 371 540 776 900 538 562 606 826 167 364 944 72 849 379 687 842 381 …
Output: 1121

Example 3:

Input: 2118 382847 224 942 592 425 532 93 891 765 527 116 782 190 506 208 494 775 758 950 326 252 256 975 452 326 306 73 620 462 933 254 820 877 646 117 771 819 485 343 724 513 488 844 556 3 393 520 624 942 260 609 780 283 852 305 329 131 611 868 858 402 818 549 746 118 623 82 413 271 982 203 962 811 998 271 131 320 804 301 139 601 332 329 204 559 616 722 456 214 898 471 909 878 586 204 883 390 118 306 944 696 957 939 118 961 604 74 986 217 965 490 847 466 465 489 206 510 866 13 704 287 75 949 548 801 254 907 627 917 300 756 988 616 841 951 592 234 230 952 948 214 931 603 737 116 909 534 642 436 203 73 235 146 673 802 454 64 776 388 60 665 818 883 875 878 858 559 381 309 828 528 982 215 571 941 31 744 437 630 747 698 417 519 468 13 322 619 457 622 682 188 8 40 524 984 543 521 348 243 359 286 161 …
Output: 733

Constraints:

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

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