CT57037

Galen's Ledger of panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the lantern district of Glowfen, Galen studies rows of panels entries. One clean number will settle the guild's oldest argument. 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 <= 1949; 1 <= a[i] <= 1000000.

Example 1:

Input: 1531 1342 713373 736605 867204 554305 541218 608399 999483 777145 869562 476543 763548 400711 793846 374923 642446 923713 356226 933311 489464 429285 194197 650782 623003 97582 786090 858590 28836 239385 278317 709537 241902 95319 561685 733329 644959 811596 818362 545226 380524 794043 445559 360195 874271 534842 819095 371849 816813 111610 980983 190624 26958 58536 238532 945416 773181 453499 29113 675886 640959 543809 885799 222634 113045 85582 434307 658925 276518 65427 783838 786439 976837 895854 210478 400622 612019 721556 603240 653177 551126 59813 725795 949034 428282 202726 49174 820254 11497 186112 528658 977120 884851 859123 475375 224572 23732 773316 702089 968990 614727 606178 320693 721695 525987 621449 940825 65512 105586 524674 400138 141373 269453 671433 343448 538885 30447…
Output: 678448606

Example 2:

Input: 428 64 331924 438366 148942 722976 379666 246814 755806 707065 693435 387799 844914 554367 504841 85272 449896 369243 614355 970170 854195 897847 496640 841480 177808 813337 392989 30579 438197 954009 115263 659477 929955 866734 618857 471932 539100 87293 99233 77454 241417 799710 37224 716617 966295 208828 207577 479384 148889 601025 691120 917213 974110 544297 617914 442376 841976 225438 186952 686483 4695 815668 323763 549954 735275 284414 78713 13230 256694 428550 789915 294200 549624 184291 876305 367629 295439 943005 704246 598837 186828 214273 170111 810459 575244 997883 92255 550031 994645 246011 290590 375309 522806 464682 596072 413474 176221 520616 464016 248557 386939 494432 438853 235280 583451 712340 458949 844162 450626 841495 958016 608368 660592 167536 46761 172475 423548 …
Output: 32816844

Example 3:

Input: 107 105 988219 248891 158330 663291 637039 602614 828941 729481 582688 775920 968173 292446 588761 838224 77764 934281 712138 324344 587088 917029 951372 560471 658215 523672 602324 533522 964468 328737 725595 415837 102741 666772 523908 732427 863675 291433 138944 98110 546998 50333 209259 243458 550029 501409 675604 693073 90298 331563 156220 929736 929451 129010 610387 913502 497716 69165 504411 439698 734307 984884 729363 606055 338256 244421 90541 315523 910052 443200 496223 324375 321426 998329 193915 376361 393124 30262 726397 413485 56104 853447 363637 204274 772014 611151 161558 772694 32508 437234 719104 740571 899787 862016 220699 760275 918598 864608 372195 99386 941234 816048 857449 322501 702580 451806 125975 532390 246826
Output: 55819157

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Galen's Ledger of panels - MEDIUM Coding Problem | CodeTikki