CT37077

Indu's Pearl windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the alabaster quarry of Whitestone, Indu studies rows of windows entries. One clean number will settle the guild's oldest argument. 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 <= 3290; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 3211 541285 333 407 404 533 992 169 582 573 560 508 527 452 678 636 332 849 682 829 667 606 596 196 665 481 2 875 286 180 290 249 169 198 685 948 526 31 333 805 169 597 910 384 735 843 803 605 465 990 876 220 201 121 709 893 33 503 780 139 390 481 359 557 636 626 491 524 990 668 870 596 410 49 807 792 400 394 378 393 616 661 769 769 513 828 829 402 439 308 219 947 904 490 151 4 826 44 769 617 223 556 526 369 57 898 619 672 83 818 36 794 221 885 701 892 653 283 751 429 450 607 24 289 397 840 7 408 716 782 639 290 257 830 763 161 33 727 353 186 291 170 498 801 486 413 600 815 892 400 202 117 781 563 859 985 636 101 308 169 93 106 660 577 873 756 368 579 345 878 135 253 338 609 107 203 783 964 469 73 175 66 461 658 421 603 369 484 468 927 98 943 973 41 881 483 533 158 702 559 656 164 9 311 58…
Output: 1066

Example 2:

Input: 532 16570 309 935 760 15 916 420 5 401 682 23 36 391 723 789 4 443 773 73 709 13 707 70 131 168 808 622 248 672 407 219 561 44 348 717 433 985 633 993 219 432 192 122 703 783 327 467 828 28 193 669 737 45 765 495 571 410 915 538 21 302 236 458 853 439 53 856 625 946 302 215 926 604 50 59 513 1 716 209 566 639 314 777 344 170 15 481 167 113 910 950 608 518 687 706 390 324 389 48 554 671 443 399 992 593 707 651 285 257 557 275 288 790 884 779 875 219 423 293 718 905 628 66 170 859 239 508 194 753 586 298 23 206 29 212 522 793 26 492 420 116 923 389 407 789 539 746 391 349 972 57 553 759 311 751 71 777 206 314 135 566 916 960 734 886 904 287 805 309 671 455 647 69 544 368 810 320 844 877 682 299 843 171 277 680 418 284 780 283 463 833 685 419 943 879 789 316 553 272 765 697 538 227 264 851 10…
Output: 28

Example 3:

Input: 2710 571243 907 355 816 873 646 933 687 736 362 156 993 448 45 792 446 190 77 344 42 449 779 631 72 169 769 984 756 431 667 883 752 742 64 709 125 400 372 883 458 767 2 899 851 438 542 666 520 962 148 766 145 993 543 446 362 502 198 485 236 658 534 184 296 86 768 507 133 153 622 180 293 136 695 806 988 833 125 661 4 396 146 60 353 497 312 11 334 83 40 612 246 232 213 312 418 69 358 858 165 583 6 241 113 202 658 51 357 159 42 310 452 628 348 238 117 975 250 789 355 153 960 851 943 766 83 944 606 932 528 247 733 707 699 897 586 561 891 538 3 361 902 894 764 225 241 61 103 815 203 775 329 702 770 62 11 33 810 781 437 849 437 920 990 238 421 26 618 1000 177 311 408 613 401 915 206 219 360 640 389 987 153 893 223 40 234 6 141 59 455 519 580 251 330 111 351 955 451 498 727 773 794 775 13 887 547…
Output: 1113

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Indu's Pearl windows - MEDIUM Coding Problem | CodeTikki