CT38280

Twilight segments Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Jaya found an old ledger of segments in the gallery attic at the mining town of Ironvein. 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 <= 3675; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 983 311714469 657801 229520 773532 721878 37123 490930 60152 94696 247897 808089 647673 509631 926350 575081 921127 337063 999745 41024 167084 323371 230139 95646 668238 342779 162462 394254 985121 864895 714048 161558 895428 80855 89882 909446 326678 986457 101617 200854 295915 688348 22679 278243 524291 335417 275354 400784 959390 833278 504104 498859 284814 40563 209880 587529 326888 828508 294990 457666 224059 286724 278910 400611 684191 614764 8778 396567 242268 228926 988858 352253 535241 649950 612298 565621 301824 236929 859262 908124 189594 932437 66047 789954 900694 67529 469447 838109 863093 66359 78918 652786 367012 569988 711907 754940 889352 167651 540201 906401 313329 64023 524235 455598 246895 936540 46251 204807 502896 491622 109417 120131 962020 433684 28147 306486 867009…
Output: 600

Example 2:

Input: 1700 143200016 166715 300652 542510 221551 479977 387425 95 353643 810127 727873 282282 326219 776972 943852 167289 916163 631998 724546 969696 249180 397266 734988 343853 280302 998057 971923 618728 788976 134945 717510 535331 482808 320781 972729 212981 442644 120398 174466 884201 383399 416385 264167 448870 172763 81879 447201 56390 92813 676684 848245 667217 893392 170911 572610 170378 403393 708596 706094 314229 475229 99630 646834 177937 927677 393395 839691 659495 753669 403905 504750 843966 250009 55164 378779 918806 689123 831562 68029 150418 180119 350462 985362 94040 67400 117490 46530 806853 955010 824054 268011 370331 538412 687692 136548 743138 583572 725894 381801 816991 232456 734086 761397 254442 556079 841162 500898 648835 169027 177414 125759 4090 690233 862588 105770 30…
Output: 273

Example 3:

Input: 1531 328784813 726662 191152 137208 390903 279564 265447 288112 86132 260814 774921 419713 949253 800434 745745 873140 172312 112112 500164 719613 145547 738689 803602 452808 25521 357167 998768 543851 545512 564318 599234 905473 183236 750117 261771 395860 325327 67854 523331 659712 257757 838234 80000 226709 683316 704138 56834 886220 743868 361139 644097 502981 435727 941427 588387 519884 958109 593078 800614 220865 303530 205923 977008 503264 80529 62418 500788 926378 573123 310016 393561 909937 115125 599798 369203 978417 190658 525462 632167 499852 508134 311229 214740 862184 650352 913539 70113 556543 579896 243959 482258 364239 744761 606223 411318 356058 243412 182133 844474 338801 741928 851878 137091 334243 934246 346027 150536 832807 318709 292877 860809 446998 498320 207638 47…
Output: 640

Constraints:

1 <= n <= 3675; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

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