CT36272

The Secret Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The tallyman Qadir has been asked to outscore the rival chapter. On the desk lies a long table of scrolls readings. 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 <= 2229; 0 <= a[i] <= 1000000000.

Example 1:

Input: 1275 1090 946733123 149625133 572176186 527265166 744180476 728712356 345604643 261723175 534982630 228834798 560919081 963873210 745761472 852214743 371821198 921150976 302592564 617472265 478989223 197354315 36054253 352779302 678980970 663960097 661012433 694002125 65320318 604998051 385490179 216319422 505835460 893931681 589773655 138267581 654115439 583125940 839773750 145318500 716643784 971128787 177701950 306652593 868893854 98793743 476497157 40747152 304087204 728812282 230391296 998021085 400986276 162991728 367964387 734690371 642361873 956135119 122660508 756774649 923590924 826872644 790035815 767948508 99460482 790116345 505373207 64325655 672350662 88560066 140050965 386902792 465918679 850288709 984370028 836840241 240071699 639467999 395833421 345827289 596284323 8016100…
Output: 555379206050

Example 2:

Input: 1822 527 273543460 399228822 868415904 616046009 974283690 833091689 721465540 875070690 604271752 803582224 272809744 655888004 214995148 652237130 638109610 749270692 492396964 534396130 981163936 414976578 868801882 291490112 527900883 618124268 186157690 290938119 475094854 226138973 156634599 628154905 49088750 165943469 889389623 918561871 211584953 742642807 203926004 89548616 288624444 57767484 407618893 531719245 299602873 619502744 462029733 21827186 338868217 538793380 638111065 963586581 860938009 47083769 357218412 940045483 382123928 332513137 702599486 449371476 54178295 896494135 656585284 462687769 118744395 696036994 459217900 151649673 231262492 662543652 963868409 450861595 724220902 116744899 127056548 875690167 874980794 142639303 650796247 825636620 169987011 6266671…
Output: 278646533550

Example 3:

Input: 1991 1028 786999994 36593973 627552010 33065446 887556305 130437424 273975700 658300867 865356394 240054696 64895722 634275776 507095186 860002879 524685906 761321324 528971498 422104176 456551334 628021594 436203663 686003531 470720308 107550393 260128719 528995925 99397593 617755546 665117613 736428938 430494354 522212901 726919900 554282142 755604789 569626644 991092837 180760265 386271254 760444520 744339656 629718512 936719929 923762267 275462107 904289096 167559467 842784337 213636293 639417035 267059750 592779666 6315518 367409811 513903342 674408033 427263474 297741536 57650767 787817264 742461395 374532366 539496264 103791021 710954670 946363797 205865524 573603669 72144773 658680112 635183305 775299962 905871072 703072170 789845103 944090217 713992870 542239981 965565320 17957381…
Output: 534038598901

Constraints:

1 <= k <= n <= 2229; 0 <= a[i] <= 1000000000.

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