CT33172

Petr and the Fixed Window Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the seal rocks of Barking Cove, someone must plan the harvest festival. This year the task falls to Petr, armed only with the stretches 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 <= 3135; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 2492 1239 511045154 458766934 13112601 419055926 649249979 616517839 208726718 402550548 428991380 337693709 256481627 422758656 523875998 337451141 718323310 565084022 873565556 281426014 324118516 555299497 242362371 50184133 725656415 351193122 340423488 564578391 93047504 65824379 34246811 625071782 337957323 420886002 357602648 385133006 287553648 431719413 419009918 953928890 203582162 357979965 94665215 58288886 908440648 488694272 130529038 960244570 476815067 295714298 552585046 476034079 782806509 18686497 398024044 275102656 206829336 351009916 488459070 986133747 957008034 60910743 530169201 134723073 692909530 408539796 80138553 247253955 303618066 776504312 80499046 373267712 278839017 31846785 261836793 463959103 309686701 166806510 404272779 897854918 424674180 45526618 543…
Output: 625246430960

Example 2:

Input: 1813 386 455780476 904830790 956858533 400236418 98761573 853475760 381257727 397332549 187646486 452898122 377225913 435105042 102957662 813350678 302198108 165729973 378291229 647032988 679836235 860598219 602428078 523962949 155440056 181621383 813949484 237050768 290931198 132910443 300089742 324565947 87205086 783129575 267579334 400073767 945685500 370495013 242781733 699319287 446780862 554943151 804613936 710559367 792584757 787142579 474952461 550149119 884655545 679008790 399574024 909095832 935585589 751911131 772245731 927213135 731341651 878891928 580013616 440751830 522714206 24161137 680773972 870127055 390215028 959326095 85049341 911917183 723166022 646216018 990285624 250718073 925798701 542752770 378448805 472390391 201361909 403940168 372463655 667970010 988270713 80917…
Output: 203069902459

Example 3:

Input: 2583 1774 814208573 205142101 600050390 294454382 282137042 399057832 989363404 317524742 636828416 333371489 237522646 994998135 798894201 19527072 234400638 204083412 756934579 688831119 155149326 75220676 892343229 833833196 302649377 8043444 248875777 534837365 182635534 174533670 410964890 323795214 432945701 114207489 315771966 577125224 552901472 86193149 465116420 52109896 40576043 842728505 158335407 682440609 130403748 228055660 696248626 781248211 184182894 763526553 411340648 804131476 732626957 295414720 660007476 957136305 111220520 893235578 804482573 855060913 3339018 962871934 162561049 908222784 724341162 676635954 837165209 331052421 956035498 885737684 593881307 330032327 202068385 409715572 665815588 579277774 306620642 458749276 596726757 199309786 693837648 964084196…
Output: 882847482065

Constraints:

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

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