CT34294

The Fixed Window Peak of Cinderline

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Farhan the quartermaster watches over the railway depot of Cinderline's stores of ribbons. 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 <= 3120; 0 <= a[i] <= 1000000.

Example 1:

Input: 3092 1513 773575 787758 381221 150074 88617 293052 46939 244187 16999 846720 556141 109826 184 198787 411577 326179 292356 446717 76852 692097 413665 545296 394746 554059 883364 171265 38451 733308 976619 717487 264736 155443 801803 770461 880635 432611 98273 854496 833012 517886 670215 912976 704983 7907 232879 444732 879540 587206 214299 148104 974277 142933 363664 156668 954682 951689 775 271419 636926 51105 24553 904539 333651 387987 267161 445924 705226 248582 427622 449980 172480 199689 363457 980970 125026 398328 717843 844616 997475 494206 497964 442855 519953 775451 980921 42552 126224 96777 510468 652218 303352 819224 474998 972514 376462 12763 617597 247267 218236 605385 227219 458141 725175 483488 582901 897216 325273 70213 429734 496566 189026 620718 312264 213344 602308 67584…
Output: 764280725

Example 2:

Input: 31 28 265756 293030 964431 721754 224836 489136 788090 423871 486038 497919 12787 109830 224772 296504 737051 607666 465612 400508 839291 270890 663411 354719 771737 810704 598211 198974 959615 818350 703791 484908 404856
Output: 14925406

Example 3:

Input: 1253 862 980332 778072 173649 846211 377455 135581 136449 189394 235188 746989 732839 450667 646843 599343 737272 693348 217189 346722 589424 907604 531116 767459 172028 474595 925873 330115 252349 981819 879820 59974 170049 395763 382023 967793 835036 965771 955107 829759 979226 408721 957180 780850 438112 574440 282367 461765 564923 10574 845745 687964 835941 851820 892414 405482 624036 653093 621241 743679 131639 138302 836833 624869 438461 816653 388810 30203 937629 977225 213918 313444 654991 485551 965482 937863 344985 222462 381026 881741 58736 283147 692578 449852 64788 236593 760765 858269 284139 98865 15355 515820 223930 172712 934580 178343 349567 688673 560683 798857 216145 808599 600952 68624 871394 677346 852810 131469 297744 34559 767392 60409 178274 999276 411400 342534 605…
Output: 431884489

Constraints:

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

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