CT37374

The Brass Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Chaplain found an old ledger of scrolls in the loom house attic at the obsidian flows of Blackglass. The margin notes pose a precise question. 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 <= 3794; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 3184 485568 568 303 719 570 378 102 152 975 817 14 197 896 746 86 596 302 682 869 814 475 631 872 438 862 522 524 117 76 734 790 216 153 779 688 238 861 812 869 169 682 206 198 45 813 710 235 297 671 734 406 942 871 289 198 395 208 73 305 35 970 741 336 435 891 78 600 63 166 497 491 698 662 393 996 975 465 575 547 44 341 825 580 669 410 516 515 138 941 719 634 550 778 850 339 638 691 633 689 760 539 154 812 949 123 437 905 884 337 454 519 30 622 966 608 553 43 289 19 801 397 978 58 543 830 57 331 794 357 316 996 274 619 158 386 986 444 691 533 165 66 220 930 619 270 991 960 872 464 204 707 932 496 268 196 872 592 454 736 392 45 967 861 563 865 646 849 974 91 32 227 278 222 549 555 115 789 277 722 722 921 653 1 71 740 540 361 502 358 428 379 605 592 252 405 96 405 417 344 169 155 814 22 921…
Output: 928

Example 2:

Input: 217 50358 412 749 960 94 570 842 150 502 240 889 553 86 470 219 601 797 113 635 408 208 977 537 398 870 660 550 351 575 259 892 87 937 499 253 498 738 157 169 487 708 347 40 981 139 766 966 796 790 573 777 644 642 647 349 998 435 978 48 130 492 341 256 180 902 136 984 726 419 881 267 778 14 365 450 15 658 535 844 782 652 27 220 176 491 377 989 183 469 883 366 23 81 413 415 233 577 856 603 201 203 216 423 12 334 943 717 556 473 580 510 87 319 35 51 842 696 497 956 683 583 605 392 566 500 809 436 455 652 94 511 524 120 701 315 187 846 969 500 170 646 475 95 565 543 518 974 257 671 562 155 526 463 51 860 277 81 590 680 311 24 758 94 107 756 187 787 433 469 422 348 932 290 770 159 713 303 362 157 906 475 332 499 946 607 990 129 503 66 361 472 689 899 344 537 166 819 601 625 731 568 880 510 395…
Output: 98

Example 3:

Input: 2682 758513 709 636 382 427 818 997 519 955 313 975 93 348 621 986 904 210 365 961 189 934 633 943 788 347 750 982 835 500 147 37 260 981 212 885 384 989 324 99 519 513 810 359 571 801 295 638 726 895 27 675 547 439 322 480 896 644 998 7 739 473 617 473 171 994 387 214 303 365 127 976 542 184 391 163 196 468 517 96 971 330 492 981 95 391 289 319 361 769 961 528 412 792 699 746 509 43 65 548 317 470 369 632 19 253 88 755 512 840 743 494 409 158 273 522 931 689 857 583 744 379 184 633 307 541 968 81 10 761 816 863 238 753 192 78 82 453 283 669 102 882 966 764 472 421 785 431 598 157 98 587 972 233 659 243 566 962 733 60 726 187 554 952 923 373 600 499 431 499 782 519 711 177 424 733 306 545 577 820 33 184 794 185 644 817 518 646 110 320 428 158 261 598 865 323 337 909 241 909 503 748 586 66 …
Output: 1495

Constraints:

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

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