CT34469

The Hidden scrolls of Yuri

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Yuri the archivist watches over the snowberry thicket of Winterholt's stores of scrolls. A careful computation stands between order and chaos. 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 <= 2293; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 541 259 -137894 669750 352659 8054 503111 217450 965069 -43932 -168770 926828 -928430 828305 -181593 385253 679437 996929 322159 246892 -882518 462925 -831141 682848 -535342 -632881 697831 119878 586393 -940229 137157 -422779 817106 723689 318188 235281 -599508 -920910 298840 506266 645090 -391036 -775334 -319503 -71515 -134486 550468 -149283 -723913 -583903 234919 85904 -93866 578102 -218029 -920377 522554 855359 860015 957367 197855 -294095 -280348 -666734 261603 302724 -168046 -442071 -944057 -762379 756264 754588 -163826 261347 600521 -944872 520669 195747 -391260 -29942 164014 76904 353186 -617961 988422 350926 986676 861273 -737387 329182 15390 545227 -124444 235547 21787 -666245 881978 35025 -141397 -817812 430827 497682 -350323 -257291 -280415 -702089 -654289 128423 -110006 105959 …
Output: 15426339

Example 2:

Input: 456 88 371198 730263 637975 -263517 612210 138958 -324998 -507473 87913 -337969 -758672 151330 64197 -241762 648075 852928 -262059 -624851 -740070 -845107 -624359 462130 -699639 71513 75659 -758361 -191400 -447049 42079 26189 -406131 454777 377829 820296 40954 -439029 512396 -219422 632999 640804 290266 -459986 565301 625952 662618 621161 -810038 -1065 304495 216491 -522982 -185552 -331527 291011 597172 -977268 453436 -737893 134856 -57715 502919 -433421 -165772 999550 125447 -498680 938276 745578 -823778 823102 763410 -528827 925316 653490 -488368 -113373 522820 -622258 -937170 -44599 419812 919763 596479 388854 109746 -813909 66247 -306944 -30012 228149 -820771 728383 30989 265156 -692964 74038 648259 -542464 -932027 592959 36323 930963 -47239 -696677 -358372 -11231 365773 -208864 952363…
Output: 11234627

Example 3:

Input: 1418 414 273519 -606769 -145807 792295 -181488 -193860 -677272 98280 282288 -605559 -19295 713712 -639542 -152222 837231 583852 970788 -733388 -604721 933477 922109 -744177 -56794 88328 346705 -335071 -334497 573337 467662 -200090 -229710 951652 848750 212358 -732284 385644 -334519 -320322 821928 -461711 -138152 -875433 -821126 -297503 -659743 491914 114224 -569387 119693 142446 276998 873267 -158736 501032 989509 -488771 -158380 -222513 745494 716984 530984 -570407 -13743 677158 -623674 54736 -642458 896541 -443382 -393665 -879146 513361 949115 -461971 548927 -943871 109179 946906 1194 -881959 870711 880687 -433329 -93569 -159190 897207 800599 133522 234843 898571 -335930 -356202 633681 15054 92588 -623061 -643626 770977 48464 580297 -130176 -858902 -160500 313374 389291 656788 -523966 -5…
Output: 12451630

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Hidden scrolls of Yuri - MEDIUM Coding Problem | CodeTikki