CT53893

Vera and the Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the thorn maze of Bramblecourt with crates of panels, and Vera the registry keeper must account for every last one. 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 <= 3232; 1 <= a[i] <= 1000.

Example 1:

Input: 1742 735 295 396 653 869 708 685 745 706 613 147 463 101 357 190 226 377 212 437 34 328 201 933 65 458 752 676 821 440 605 537 504 2 646 920 519 510 248 260 801 147 581 569 279 511 859 641 833 607 276 742 520 265 831 612 738 535 329 284 967 652 91 212 320 884 104 950 836 748 241 772 70 792 858 118 268 393 579 2 496 927 755 743 461 141 995 804 582 808 28 233 52 59 53 361 767 367 499 649 716 559 300 916 183 765 512 222 866 729 434 145 526 939 434 768 169 889 222 383 232 748 188 810 528 952 995 510 743 830 767 700 447 487 486 186 860 151 972 806 596 150 831 122 243 75 385 671 871 385 958 732 591 811 634 852 21 996 625 870 696 427 547 301 296 48 968 775 39 908 125 886 681 527 274 635 941 687 426 812 98 634 215 436 915 768 308 175 227 398 320 432 78 595 421 930 203 122 444 499 66 228 431 718 99…
Output: 378632

Example 2:

Input: 126 69 380 901 515 832 299 169 495 425 422 600 728 820 328 355 14 215 98 358 26 548 625 90 603 97 307 599 978 822 325 230 863 720 728 419 561 456 497 677 437 269 63 3 628 755 463 378 546 932 167 598 21 451 120 163 536 112 912 382 704 605 990 344 494 658 461 686 34 794 137 184 769 866 263 641 605 415 580 753 804 240 304 185 658 369 176 882 693 138 70 533 75 66 638 907 474 751 587 815 990 420 424 755 138 694 405 931 960 98 418 979 994 211 518 698 698 744 504 175 789 701 610 882 35 974 590 494
Output: 37977

Example 3:

Input: 980 809 19 539 68 19 381 639 455 770 997 586 839 648 473 743 871 330 780 201 833 401 299 365 81 494 507 770 289 439 471 291 293 71 528 542 257 480 271 972 610 348 181 724 227 803 980 644 104 605 572 317 535 69 549 404 338 770 326 126 30 779 132 407 284 646 309 834 32 268 951 201 188 815 542 557 585 39 541 740 926 840 197 643 696 28 308 853 95 133 790 926 696 941 496 674 350 60 383 722 378 939 251 161 920 487 661 165 525 458 602 613 872 236 736 630 405 387 361 86 230 77 421 624 767 592 504 800 457 440 687 974 174 634 139 104 863 950 305 230 134 932 535 225 413 307 368 877 513 150 561 397 980 415 658 27 284 563 611 456 875 396 970 211 69 529 331 957 95 181 422 557 865 765 695 977 288 513 887 618 771 870 69 100 288 620 999 367 598 967 746 958 174 246 604 697 535 343 477 441 871 981 341 215 58…
Output: 411148

Constraints:

1 <= k <= n <= 3232; 1 <= a[i] <= 1000.

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