CT42781

The Granite panels of Devi

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the silver mines of Lodebarrow as Devi unrolls the day's manifest of panels. The tally will decide the next shipment. 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 <= 3612; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 390 139758 320 97 754 49 719 531 318 146 586 116 901 18 918 25 129 202 384 529 792 148 905 899 532 422 606 531 659 301 197 752 824 87 644 931 995 970 65 564 21 100 695 385 306 549 181 648 669 217 531 276 775 396 77 545 50 353 161 947 242 157 411 48 971 450 96 756 178 628 407 439 370 83 526 368 572 183 335 59 648 79 100 655 568 491 772 992 724 493 678 382 817 364 964 34 717 745 563 529 184 274 859 690 498 719 150 944 249 846 962 705 143 978 290 431 447 280 60 560 949 505 631 369 361 720 136 454 853 614 148 534 205 276 651 81 415 475 941 613 894 343 332 6 876 895 308 276 394 923 469 32 381 488 821 885 123 179 672 894 436 998 535 613 592 247 125 159 170 252 631 304 885 519 439 337 733 525 880 455 860 172 931 644 712 12 973 716 68 804 368 148 773 421 425 313 305 850 379 355 402 835 276 192 71 …
Output: 292

Example 2:

Input: 36 505 560 489 864 239 109 200 548 322 714 595 231 693 203 743 519 354 637 342 951 285 364 134 112 450 314 8 471 832 144 50 684 886 870 862 570 1
Output: 1

Example 3:

Input: 611 43879 795 640 335 25 1000 79 557 222 678 85 87 237 42 611 435 701 323 590 278 391 36 156 133 455 442 253 946 519 225 299 701 386 999 562 78 507 882 120 47 982 925 250 184 720 550 718 217 375 368 344 129 507 245 289 472 629 118 70 552 865 392 665 674 972 54 377 534 486 352 82 474 862 53 754 997 949 302 689 640 257 378 798 839 570 353 621 964 42 289 773 800 561 936 22 704 480 215 803 641 326 101 719 161 917 978 837 883 140 172 519 818 765 267 178 273 542 373 327 827 697 932 702 558 967 971 30 729 639 700 768 220 443 762 808 507 386 521 556 746 115 440 180 108 625 548 533 203 814 91 431 892 659 840 419 797 283 552 134 649 989 533 254 988 357 420 707 578 440 820 158 956 647 1000 861 35 937 854 866 849 201 981 16 576 915 374 67 225 368 889 101 469 455 300 532 899 398 146 288 443 723 873 31 …
Output: 76

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Granite panels of Devi - MEDIUM Coding Problem | CodeTikki