CT42418

The segments at Nacre Bay

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the pearl fisheries of Nacre Bay pays by the answer, and Tailor intends to earn it. First: the full register of segments. Task: Print the minimum sum of any contiguous subarray of length exactly k. Input format: First line: n and k. Second line: n integers. Output format: Print the minimum window sum. Constraints: 1 <= k <= n <= 3943; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 107 98 -376283 846036 285591 -905202 -417698 -387484 719356 567847 -633619 -573622 925073 -936364 581796 -34405 815113 -454905 -210221 -149669 -894497 455712 -688719 217049 390950 -168493 -597083 904251 -800403 821244 -411795 79763 804514 -837245 571292 -175621 21785 -629291 594242 547690 -15884 710124 104500 930698 619181 26361 -332167 64743 301252 -416849 -540314 -330950 -581356 223985 706818 -429236 492957 533564 -298344 936254 415889 976972 -416832 690530 -282 29267 304258 142488 -224350 -695500 824714 248445 -647261 -150342 66277 178505 30774 283746 316183 468937 -826195 -597975 -664670 -913219 -663666 45444 975755 -491057 686000 112070 -607188 -880012 -844327 274468 -618314 681649 806242 -962781 -917877 -648363 -647067 -413707 232846 -92074 319545 592037 302072 -375366 100761
Output: -2222848

Example 2:

Input: 305 164 370760 156790 -702823 357937 -817968 144790 -631623 -138075 -185557 -7085 257852 -431829 -984976 818017 505026 -579294 -397397 416341 -460365 954079 770368 661089 -322976 -385793 943800 -94128 -459071 -728161 146361 207068 740195 406505 -674090 -936860 364931 56781 798493 -298784 -835361 -956450 67279 -180128 112195 -228674 658455 581019 -304544 870539 -70183 821013 366116 -581723 -606226 -890290 641218 -231072 386250 889209 -707752 -923700 -810011 701338 486053 818336 -322086 -807537 -909755 -673976 -935277 481706 520973 546881 135158 470096 479349 387869 385473 -222602 944108 -819273 221833 156842 -596889 -837696 217286 -705744 -785975 825028 -330058 -678603 -979510 -897627 -756071 729754 -353704 -256567 1535 -482414 -55994 -880513 851218 -840386 -145328 -397418 -58725 -659156 -7…
Output: -9463537

Example 3:

Input: 249 65 -420253 875590 549815 381890 404843 833930 475041 167848 810207 -394675 475674 -777315 323556 -460544 -162543 -794985 170140 -515656 593638 -185368 -169429 -680787 215384 844486 -847889 829826 -782524 357452 -339988 -898220 -188130 39358 794928 998099 -352330 298365 571714 -217881 489851 -888390 -736639 -55616 696867 -68935 330589 648666 -685504 -477401 200589 992744 -888078 -302748 812341 -223336 107517 464022 -744968 -161090 -440318 -401687 703207 -137379 634628 -919887 379027 840023 -533272 -196026 -594211 4808 943514 -47240 -211732 4984 194921 -165518 -677174 604500 -36658 -443127 377789 -491498 -44777 -790045 -959245 -726062 -904592 114682 222472 -656280 -758175 -715166 955020 -473891 -287491 120618 -707873 -184408 668729 -22343 -66482 196941 -18721 780925 343466 -711513 199167…
Output: -6334094

Constraints:

1 <= k <= n <= 3943; -1000000 <= a[i] <= 1000000.

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