CT42093

The Tightest Stretch of the Vermilion stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the bamboo terraces of Verdantstep. Tarun spreads the stretches records across the table and picks up a sharp pencil. 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 <= 3008; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 2011 234777338 12074 564292 147135 884747 174611 337421 519261 318960 925201 631079 607730 898658 971474 581054 896226 951180 806011 836408 379924 820844 623649 301977 404054 518413 609643 916050 809448 982699 558127 351350 713997 709952 869874 312678 754325 880564 580363 204244 502077 830383 200707 951863 49391 965214 575723 231199 36677 912385 301837 828889 614466 812388 344835 571085 752992 538729 637349 927857 667798 357835 790743 803387 29029 919898 9711 657117 625277 83887 890166 708688 136107 106156 446591 305941 27361 30015 486368 141550 594511 197290 390055 603360 672218 55400 509558 827743 264794 127411 698038 313439 867011 972508 443547 421003 516296 480487 415817 156740 760514 187827 573580 957285 34973 801477 31873 123237 833409 31656 783866 622331 805325 538966 359428 190644 …
Output: 448

Example 2:

Input: 424 144704873 121223 775700 417481 246802 901857 602444 42652 860485 294773 775509 462856 838227 276034 669396 374368 554082 58344 441477 62104 642993 57032 847347 774705 565759 59314 323978 862355 506835 950068 37680 532035 992900 322782 760786 154212 965215 27946 424752 484125 430301 737340 373453 987013 72189 216536 720857 692745 465613 987397 880016 306280 31419 114829 503193 804633 618553 655851 997864 717873 248385 252901 479725 866764 216563 753305 491736 722104 661741 276600 611824 167238 963384 705381 504570 947496 231572 402208 950601 382075 341950 171111 980054 324838 638623 621969 244193 393212 312363 34504 893713 998507 542740 421017 873067 77758 424260 520151 362973 154874 636487 834662 500688 321490 350036 705326 811616 128986 200445 139359 434993 699644 3355 284318 343642 4…
Output: 275

Example 3:

Input: 361 171310464 791657 447495 6202 790707 560153 850738 142237 417563 128759 366127 520164 671833 357891 967033 851358 626247 665317 809381 388195 247300 32605 293749 504656 273261 927883 496633 650478 39261 956216 692515 28616 737799 109707 624025 559577 732115 912012 728761 43516 849964 449066 521611 215130 658529 957964 437950 673686 802649 507188 548506 151081 117450 220234 65505 695510 575492 44733 629482 441307 343446 517843 642156 543705 356816 814052 100321 20962 341606 563320 183979 308198 805283 289211 927726 645494 984031 782867 931459 479914 764406 196436 740786 608290 145599 490237 69987 880247 644056 930775 420231 351688 758721 240811 635512 526708 361 290060 749431 497737 751336 28242 266273 685775 264196 552520 474827 696093 317242 811801 513904 361658 528720 639278 280517 19…
Output: 317

Constraints:

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

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