CT34273

The Fixed Window Peak at Brasshaven

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Eklavya runs the cellar at the old quarter of Brasshaven. Today the books show a list of panels, and the numbers must be worked out before sundown. 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 <= 1466; 0 <= a[i] <= 1000000.

Example 1:

Input: 417 237 420936 753239 275974 846552 802518 825194 320732 984401 950499 880090 231147 106856 976450 265122 791237 240586 731412 570072 90892 413449 350268 785821 671015 587943 462067 767703 922752 251182 207861 704780 687690 831023 243697 642097 996700 67181 910529 934594 618063 674368 833224 67250 409785 127039 203665 235256 946364 410787 345275 906807 634856 906006 426721 772266 82448 509785 144763 257682 871367 811758 143088 778109 486972 713647 488671 978862 99851 378444 582207 444612 725809 17228 502413 703653 657173 822046 654861 428958 769319 588731 878125 952803 359494 569190 24620 816269 720090 280610 87029 50878 239978 517939 885915 174405 7853 270157 158918 927307 785174 912382 220894 263740 423791 506494 95762 101455 885631 49823 536460 94574 237915 815467 952147 994515 324360 3…
Output: 119765001

Example 2:

Input: 77 51 890916 907358 21795 858328 323253 413247 972870 57993 743750 245700 837224 693915 613263 603392 537540 486088 724578 38552 134178 738551 445552 547360 843819 31681 435390 933294 987720 904742 159306 892296 942330 944120 40775 457001 53285 21779 718337 450344 621161 608447 848034 56087 466684 561177 300499 187011 469179 233515 169660 471702 133705 204637 855186 161793 661746 579320 99146 906527 343182 115170 588666 388864 490204 883790 775085 902198 127789 864397 731488 723559 920600 25589 91577 765198 522710 826242 97051
Output: 26259339

Example 3:

Input: 387 264 134845 181214 67714 467286 503582 211797 868877 37430 692154 63551 824439 810932 574408 809105 947870 153956 493757 56212 991024 764473 71521 352352 336726 73885 420984 261433 376207 846259 89114 873754 19388 239567 457830 610239 9332 153771 5443 90150 167009 623654 148165 481207 969073 500940 74729 604431 881226 179073 661710 20455 397720 359549 687372 463116 10293 322432 849694 455044 67600 554102 266595 412528 240684 756546 400177 983629 939188 759830 538451 300664 835923 525090 86195 908313 369471 279230 445051 133467 548952 383323 840586 963744 191427 73979 914819 143493 540323 632236 393935 54835 174017 860471 835066 450853 156809 742945 91221 234652 850561 106910 70085 932892 727790 561902 361126 576009 419869 347308 387753 468538 794399 262941 441006 267452 857974 758426 56…
Output: 120574983

Constraints:

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

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