CT34823

Mossy stretches Fixed Window Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the mulberry rows of Silkmead, Gita records each stretches in a worn leather ledger. The guild wants answers, not guesses. 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 <= 1149; -1000000 <= a[i] <= 1000.

Example 1:

Input: 352 85 -321826 -498218 -85515 -99975 -491812 -780143 -918964 -971942 -524266 -5320 -58519 -463704 -302104 -764978 -647436 -111068 -969065 -266852 -992835 -237598 -773926 -922656 -705826 -758294 -996552 -471049 -15384 -75612 -542381 -87228 -196203 -995013 -788993 -571580 -879057 -166410 -287489 -998863 -40098 -676723 -482818 -333108 -501917 -238631 -818829 -993089 -664936 -940333 -986216 -550065 -583812 -930705 -696805 -178666 -510453 -134561 -32684 -239791 -823128 -52345 -243134 -207713 -892461 -510062 -50914 -906364 -140492 -573780 -975911 -627836 -453817 -866457 -598563 -536932 -919162 -905922 -810705 -211115 -947754 -16351 -266903 -850475 -166487 -188101 -796484 -593323 -684662 -115341 -89710 -171273 -898144 -209720 -420976 -53183 -963003 -288532 -820810 -787910 -95008 -910824 -854083 -…
Output: -40621546

Example 2:

Input: 469 401 -875175 -848140 -954553 -345255 -628774 -529725 -453232 -842247 -146332 -412770 -813224 -915749 -104274 -83591 -488238 -458775 -898514 -915581 -92453 -146539 -226973 -912743 -371373 -820321 -781155 -285070 -480186 -419454 -702687 -166033 -902977 -634931 -993638 -514682 -756991 -497680 -23905 -540479 -867082 -381931 -866866 -972529 -216403 -890262 -9426 -253586 -669887 -323343 -654230 -394333 -346778 -549879 -191094 -867358 -380488 -203343 -576107 -732309 -826759 -102944 -286044 -516060 -655697 -548911 -46407 -830036 -159097 -514914 -618900 -162807 -39975 -359847 -184579 -518682 -457700 -219355 -596423 -245482 -725305 -628738 -667299 -868305 -898787 -706183 -274960 -570494 -100208 -628051 -204489 -915507 -824196 -333292 -745087 -504617 -339866 -225490 -22177 -353378 -148672 -724104 …
Output: -202606719

Example 3:

Input: 830 64 -111378 -940267 -961462 -224511 -406414 -866849 -430749 -115646 -672434 -504788 -696038 -661590 -164565 -10796 -390692 -734048 -693299 -707942 -947008 -526153 -782330 -772515 -619148 -418582 -380262 -622191 -465902 -622041 -705740 -5974 -656374 -660646 -530434 -48262 -250465 -461250 -625955 -88283 -959644 -859988 -442223 -678076 -634426 -990029 -188368 -671010 -403330 -112959 -76766 -197485 -11079 -916575 -643214 -872167 -12486 -364610 -723421 -385951 -122154 -306075 -195025 -47433 -321917 -153461 -550146 -522085 -391216 -631809 -423396 -349667 -245438 -766282 -891290 -985376 -568504 -142898 -709217 -299218 -864764 -264775 -907050 -454796 -860757 -212341 -162582 -504154 -603641 -594572 -525364 -882295 -327569 -610259 -976823 -932854 -511165 -513191 -109850 -179485 -103826 -485546 -4…
Output: -25468819

Constraints:

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

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