CT45975

Tanner and the Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the canyon post of Redrock; Tanner weighs the day's scrolls 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 <= 1765; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 1739 35 -770775 -225615 -419960 -414898 174053 -752950 -942961 -813459 826368 -845411 240780 -177714 344862 836778 411033 -421877 749684 -744645 -774596 207940 465420 323820 -528210 -972196 313073 190373 725476 482225 -395810 46733 83044 719823 -263778 -364400 -848566 930630 -77330 281325 963083 302320 940554 183880 839496 205786 -510096 422187 -271774 -788928 654811 -925502 -321491 521674 -999034 -459928 -570750 852790 -699586 -599562 371877 914627 -486259 186930 -802918 137123 -247292 -143670 -109268 49221 -183870 970393 103619 227047 996052 114885 -284010 255139 237102 959866 68307 347801 -250472 -748143 -700298 950149 657444 530129 711087 -231428 361132 -789781 -86305 33647 496913 692482 113605 -147618 916742 324315 241123 -761855 -267571 -786690 151644 368664 170505 -626166 644150 -21…
Output: 9450115

Example 2:

Input: 1620 70 555589 512739 -330250 856440 -887735 -559205 -664844 813544 -166010 735507 -522310 -346353 363993 -817597 249771 -764402 927099 -90672 290567 -940075 675757 -625623 -323385 -866241 801491 697137 192955 -876278 -358364 -219036 -644178 66062 -124754 699845 6800 -268406 -687570 756590 -610520 892577 -510466 -430696 -17842 631132 250295 636762 350678 212115 -436237 800656 -495765 438582 591907 181190 -740790 -796263 -426864 -937101 -450215 -53162 602643 425644 -359764 -771475 936759 291926 -966141 452028 -109316 118665 873121 -827901 -820120 22441 893443 598218 702282 643065 -926788 -145994 159380 -127848 -545996 -737676 626089 810647 -953681 -920097 772083 -519795 -938850 893205 -857445 467882 135130 515333 -817627 864353 -463750 -51847 -513232 -502665 -417344 786941 126596 869391 960…
Output: 13667659

Example 3:

Input: 263 246 226650 752253 -718786 -442131 469639 -835908 58342 -27745 324680 -633721 980636 760780 703854 556052 140226 -123319 484031 511388 827030 750556 -844290 -213600 181532 581840 835179 -555081 -783568 157281 135877 545253 940650 -362120 489910 -515906 -662338 -640308 113334 -409313 -373931 447358 -236103 -694704 -445452 -105614 297280 -297835 962261 219718 -745009 209238 175590 398644 -982705 -209683 379638 191891 -110166 -39510 960923 92356 -434477 -363375 324496 -307246 -14471 -776004 348658 -535688 -55487 -801091 -757590 738351 -513647 -477451 446419 -103401 -870403 427861 331832 -135422 862607 611029 856687 550731 787981 -964671 -629644 -85650 176525 -355925 17677 -353324 196699 771521 533205 -437419 -914025 -353131 829928 432459 -697430 383965 -44494 -503373 -653549 -381890 -27732…
Output: 514277

Constraints:

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

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