CT42938

The Longlegs Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the heron rookery of Longlegs, someone must track down a clerical error. This year the task falls to Envoy, armed only with the windows register. 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 <= 2339; 1 <= a[i] <= 1000000.

Example 1:

Input: 683 650 655930 272065 602936 980801 633966 282710 573554 953807 747173 44037 641251 981228 925465 777054 452539 707718 890572 21176 167944 282235 708074 128894 549724 765306 248190 646782 417984 12588 454471 658331 675214 775733 567740 245280 872483 381633 293231 184628 481137 605323 230630 750939 392612 735562 969605 173823 295277 288771 580732 96869 330926 715481 202166 22937 147261 647985 134219 831520 695485 234222 310067 158663 784717 921830 662598 431616 202542 143266 13308 471247 706109 220936 497392 579474 282268 871503 423984 363266 871152 178272 523443 948678 171101 302435 943042 275447 183437 941406 398060 147408 597286 134813 2835 181848 638491 897268 238830 710684 728783 166374 899415 733322 519131 844367 847950 745648 496036 581773 478949 876154 364387 657462 37494 874018 672…
Output: 323433049

Example 2:

Input: 87 87 170108 273946 201884 229648 89638 901950 144773 333805 838207 960508 211902 924197 4221 252137 737168 840675 264397 193307 983458 591578 386201 487828 771695 932195 903650 995655 189061 189624 645912 828141 312632 694342 124887 78510 470792 178994 708039 166010 724657 507791 203972 734813 37215 862253 500267 169852 670429 948714 981259 262835 409245 568411 991834 830595 632585 82617 662525 602237 555414 325986 786063 216243 524776 92707 33708 754223 877645 673033 917330 768831 843958 415169 189742 625403 679486 843648 737315 913341 921285 491292 521728 697233 795726 137686 116193 333610 919472
Output: 46304027

Example 3:

Input: 2131 615 461460 305237 731796 654423 812787 707996 421722 778213 474711 504002 59449 386432 540797 619535 850931 726509 427064 790475 747275 638431 70689 54110 89253 33504 973868 339944 446321 646551 365684 718262 856253 755180 51965 97765 496383 221076 460015 369537 207647 93718 84256 650452 198018 141384 242230 823220 230382 245014 631426 745833 168998 9279 599374 170784 158394 392997 88822 203317 656638 719614 252575 737307 766517 689033 655781 559140 239657 854397 729194 704507 698851 409985 798406 58843 281495 244959 588609 12735 804748 852152 460533 23251 467294 83594 517391 469262 783697 279582 772025 726133 652105 809276 349703 874103 440618 52269 928822 469330 424346 235343 178550 876694 278799 717603 875179 7807 825933 647547 344444 162410 497043 345132 999558 395723 100808 4100 …
Output: 319062828

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Longlegs Fixed Window Peak - MEDIUM Coding Problem | CodeTikki