CT31613

Dino Counts the ribbons

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

It is audit day at the snowberry thicket of Winterholt. Dino spreads the ribbons records across the table and picks up a sharp pencil. 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 <= 1811; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1004 234 -968483 -490029 -942228 -829738 -232622 -654772 -812902 -307402 -582162 -807718 -16846 -663868 -243132 -953258 -911178 -759386 -21523 -534092 -203791 -488183 -170439 -490772 -582825 -956396 -153551 -722700 -893223 -780678 -908382 -135681 -397083 -212990 -643433 -656893 -545888 -899221 -987749 -768533 -453900 -295921 -762157 -592848 -796510 -870101 -892849 -543016 -298003 -728440 -914103 -664106 -564923 -112008 -295360 -595693 -276167 -522050 -196319 -427078 -380080 -451223 -988005 -145187 -976681 -161786 -513191 -495625 -422133 -729304 -267645 -260924 -450127 -787496 -435861 -829826 -891308 -427895 -727130 -844982 -619287 -993020 -97540 -919089 -43254 -162861 -722843 -864000 -73421 -893452 -713605 -955735 -632203 -857952 -527801 -460823 -830034 -715043 -388303 -955624 -239624 -588…
Output: -108959680

Example 2:

Input: 1016 846 -83063 -296121 -416517 -294456 -471317 -606658 -78412 -720712 -655641 -832096 -301444 -101252 -599766 -216278 -769667 -935233 -557738 -499025 -569393 -483259 -585274 -160611 -879747 -497023 -555711 -547044 -680640 -886614 -803651 -609128 -689057 -453372 -681978 -231249 -518033 -186035 -305902 -504557 -574891 -181828 -664871 -493637 -653552 -789342 -908828 -196768 -67656 -1790 -749928 -867880 -338150 -260580 -93451 -889271 -999343 -430780 -353876 -548717 -285051 -157066 -107417 -200374 -669415 -631221 -85267 -113088 -147101 -516931 -790069 -967398 720 -934853 -139209 -790682 -266827 -958074 -895398 -492242 -150064 -865773 -553568 -812703 -741409 -986856 -530522 -96785 -402594 -805997 -228775 -247603 -740444 -570629 -417547 -946010 -145449 -151329 -361848 -569568 -662287 -614666 -38…
Output: -410725149

Example 3:

Input: 1139 188 -684160 -272120 -596834 -785733 -531038 -860621 -349712 -483985 -92226 -666712 -355418 -383424 -521226 -522929 -358181 -103240 -370345 -724562 -138688 -238055 -478178 -481268 -410469 -208769 -15994 -702035 -145934 -810150 -398361 -777137 -404313 -126298 -838148 -810640 -95363 -669523 -985228 -636972 -391857 -818250 -838258 -228078 -825403 -944565 -423216 -13633 -114850 -409197 -281339 -934674 -31492 -634353 -855852 -191720 -860819 -663002 -872959 -790 -982534 -202294 -726986 -647418 -845149 -93190 -527167 -716541 -159751 -425049 -582812 -45594 -160510 -830220 -500885 -860136 -127955 -364007 -320624 -574836 -651881 -958462 -766664 -687361 -817672 -409562 -676033 -969970 -889468 -441765 -77156 -35877 -718367 -653173 -45372 -149422 -7595 -267192 -70693 -8362 -324911 -58116 -55603 -36…
Output: -86132481

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Dino Counts the ribbons - MEDIUM Coding Problem | CodeTikki