CT34728

Nila and the Fixed Window Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Nila the tallyman watches over the willow walks of Reedmarsh's stores of panels. 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 <= 1932; 1 <= a[i] <= 1000000.

Example 1:

Input: 613 468 427077 202101 569860 131340 637103 260124 218183 468164 564108 807225 305559 358497 505381 594655 109136 572530 969719 95924 3556 177778 354577 741774 316363 462509 931685 94821 288288 770218 91799 912113 530511 576594 968318 135016 171706 769786 371933 625688 243282 403643 431926 818897 723938 263349 675624 596848 129928 384276 218118 399237 658282 963297 383554 996006 33571 651061 713951 606203 234746 84536 683590 992221 647148 759935 843606 180328 965920 285575 802048 707261 418893 751365 416647 308460 356011 297894 995411 371431 467519 970191 159355 619783 433759 769597 547725 830682 494156 33429 582663 193192 346431 605075 534740 648823 753645 355411 891588 663424 892996 495348 953865 335877 276204 829912 662536 559600 595906 848455 71112 40786 589228 730244 378826 564566 7949…
Output: 237019750

Example 2:

Input: 431 332 383826 606645 994914 20443 468993 873695 368905 37507 771814 324072 279927 795414 905812 553197 331470 40849 690511 988525 499788 877971 11568 925521 741354 836994 922765 537392 854830 724766 546639 567618 995090 41449 20123 760563 757321 67566 632689 956412 54543 44153 958714 105081 31304 787714 323198 64373 892938 10170 973873 708060 358252 190373 394370 44432 441035 387495 854612 354490 498766 976571 911622 151513 114225 826099 230071 181974 453410 760435 372202 775501 130955 787310 994455 212084 613566 595395 279635 128511 963520 116333 328549 950910 324638 750484 650043 301111 798306 320197 168493 867170 794012 284720 727744 100827 979844 336636 783370 310776 182877 684879 703150 60763 369058 888923 41200 449791 462855 952027 460473 758344 263147 839619 461400 255506 760363 72…
Output: 167441237

Example 3:

Input: 1926 32 168616 969668 44984 513078 902999 94587 761427 311235 619824 36353 25025 332277 115584 496874 983345 573436 27409 514250 183154 67835 88783 223578 102999 394614 358880 96104 251617 118673 320930 142788 894694 262116 548041 935479 513673 531088 315268 62969 808813 67303 749464 925948 133770 57892 380634 885354 453957 362342 289823 967930 296199 499312 743136 556667 203602 613504 867956 858994 144611 933735 131928 479442 325903 181891 709991 649051 595677 184368 831683 200212 233573 550290 80984 41087 539384 330904 636871 864480 724878 931062 278267 62330 667878 585235 196536 295434 378405 305347 115455 371135 992335 417088 32371 826325 833904 506916 832529 840388 882045 174406 609771 726720 506062 655787 218642 518762 433693 975273 236258 576208 463799 585974 751024 475691 106622 24…
Output: 21244058

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Nila and the Fixed Window Peak - MEDIUM Coding Problem | CodeTikki