CT42515

Quin's ribbons Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the wheat plains of Amberfield pays by the answer, and Quin intends to earn it. First: the full register of ribbons. 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 <= 3106; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 2846 793068995 502512 551333 900410 1399 427335 59738 77354 681168 60859 88765 632865 273192 927081 890335 882266 611897 644335 824293 862179 194806 203848 252730 170493 268981 330999 191461 719805 491818 845445 267952 479808 99175 623496 797654 940596 319753 50133 615546 864347 371403 897761 708520 600081 252758 195552 411349 628238 447811 670060 238269 20300 784745 900532 130567 410383 945288 964891 296557 941926 867770 737260 968383 985608 851409 924100 874998 189577 743226 967841 80561 306059 705979 876365 126564 674083 96089 528900 702749 970965 651955 227592 929745 341982 899561 745176 776990 905703 12935 967060 275689 435191 392058 974858 955892 254217 799639 432863 562858 564972 342344 811908 387987 547324 570478 408602 508730 708885 825360 292931 210511 309243 642482 466400 745037…
Output: 1580

Example 2:

Input: 2994 501769044 70185 730752 932241 340249 356252 116726 241909 562199 466917 613249 576444 639776 782085 30303 195878 742225 759111 151746 606803 319531 245510 856006 607604 282941 628134 225602 449798 291265 14157 909972 807971 836195 179555 867269 406340 462112 367655 479902 960108 671619 354714 662777 1355 356867 208004 634168 807463 257508 170145 58377 271942 713841 713908 149751 476774 134871 191982 263842 301107 839013 39738 120112 756633 978943 654286 141199 496764 935683 750452 921508 415681 432426 322158 412939 257509 810366 877981 871267 315802 995285 924596 163777 983232 352975 921683 584132 132895 60719 370032 78179 136248 844138 254218 208706 739785 995175 818328 508079 83084 166712 77821 471937 738513 736705 525294 658867 400305 956628 621423 776450 452428 175973 803844 73886…
Output: 969

Example 3:

Input: 1068 287865037 483054 295524 854058 730753 491752 915670 23945 112834 889648 231940 857640 917415 236071 465119 145055 548072 323804 572693 357429 631647 569985 302912 66405 793491 861607 366692 198375 974552 847182 885057 582627 627431 721195 209047 599893 568155 792683 173562 578996 233615 213836 919042 853806 989077 960318 571474 273163 999446 543542 569678 812008 216875 484917 933598 74484 139420 468005 145582 488133 393481 289910 819019 408240 430971 321042 915262 275825 239602 826909 595736 24064 748208 472647 353898 837641 533779 378278 19879 601152 820272 737145 635699 240284 882475 738874 198560 702983 360709 569723 684446 922520 194031 848700 230311 820751 715913 581540 609435 480678 757645 717810 700515 489693 971883 925530 687140 807750 386649 576262 80866 181908 863738 62431 5…
Output: 546

Constraints:

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

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