CT44511

Aria's Frosted Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the gristmill of Rye Hollow; Aria weighs the day's windows manifests and starts the calculations. Task: Print the maximum sum of any contiguous subarray of length exactly k. Input format: First line: n and k. Second line: n integers. Output format: Print the maximum window sum. Constraints: 1 <= k <= n <= 3688; -1000000 <= a[i] <= 1000.

Example 1:

Input: 533 444 -611835 -244930 -164413 -598878 -22052 -597620 -308126 -450666 -173118 -991426 -277263 -593772 -872419 -32328 -457299 -10956 -293126 -358893 -152664 -316548 -118156 -495959 -983094 -141376 -534164 -596922 -586879 -908116 -220968 -250763 -826972 -193873 -13275 -713902 -308555 -281447 -495726 -745236 -149960 -719223 -922990 -460333 -462082 -42887 -387847 -584636 -217949 -455276 -18293 -373208 -740008 -682667 -121461 -399849 -252021 -314579 -647156 -212059 -204258 -455746 -638202 -187618 -814402 -836089 -987851 -551760 -866739 -247032 -699807 -816318 -769484 -707625 -581632 -470993 -659379 -583416 -732647 -268044 -280726 -68232 -11766 -547155 -530057 -359538 -203719 -303487 -358007 -885302 -247400 -419595 -38733 -117124 -781067 -560515 -769315 -285948 -983712 -867510 -269939 -943295 -…
Output: -217644124

Example 2:

Input: 3621 2658 -461065 -200186 -358818 -46687 -234121 -277578 -350398 -807163 -874809 -217597 -476426 -930472 -700793 -812763 -853283 -570752 -667728 -926196 -840017 -176292 -484857 -171475 -955773 -67544 -440561 -509397 -403014 -931359 -452289 -680497 -857387 -254164 -269706 -455989 -667954 -111061 -214831 -452582 -105664 -311478 -458327 -548134 -963728 -68220 -229852 -231166 -226857 -620745 -292770 -419504 -160657 -290821 -28678 -231110 -64666 -321615 -888135 -977334 -970881 -806571 -997651 -569541 -138139 -456651 -292410 -289829 -887360 -109338 -729474 -399489 -414712 -218914 -922908 -833031 -279028 -991916 -101801 -546813 -75637 -992232 -665414 -16268 -853011 -495678 -132875 -826654 -772078 -3770 -999570 -922855 -913107 -993838 -708213 -49931 -148593 -497164 -386184 -875207 -742446 -846412 …
Output: -1329148502

Example 3:

Input: 3022 1822 -677146 -487958 -268624 -17489 -789409 -324669 -252785 -255631 -895490 -761566 -881947 -831229 -928953 -446363 -980585 -481052 -353657 -408182 -355507 -103088 -145068 -893161 -729142 -398552 -728734 -802843 -289120 -513035 -720815 -695200 -102262 -7935 -854259 -566463 -38053 -460775 -45894 -736457 -268147 -443929 -69953 -37495 -439831 -465317 -439172 -555260 -522569 -667547 -405614 -736401 -867762 -496248 -659977 -8793 -326083 -202713 -350757 -529655 -335531 -270330 -157259 -227885 -190846 -961368 -196556 -277899 -808348 -128909 -710388 -811736 -371812 -923465 -511372 -474029 -987630 -944011 -857552 -667625 -899585 -445506 -798594 -633220 -780597 -947335 -486471 -426758 -524693 -868831 -306374 -572195 -742407 -189168 -937815 -610834 -799325 -100010 -332925 -57314 -677687 -717492 …
Output: -892959128

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Aria's Frosted Ledger - MEDIUM Coding Problem | CodeTikki