CT49661

The Fixed Window Peak Beneath Buzzwell

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the honey farms of Buzzwell; Aria weighs the day's panels manifests and starts the calculations. 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 <= 2969; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 115 33 135325671 380080061 775475313 654220949 853144077 124000458 587923149 636136386 62767552 22878532 498619598 988651847 461083580 598375585 240233397 585575932 712993950 663972902 294353033 809551073 123707345 877006865 280076724 975685976 876687518 951086193 37349864 892625291 399090201 53681921 195353285 405749213 796179416 575601683 520011205 450732031 841015225 55117541 911429846 447051604 718488417 358349298 203244885 401853267 128067107 130976191 420919440 782550160 804959553 99411017 178979445 867263012 154815066 130907608 781442507 572927733 775598258 719375436 697228354 560487159 759676696 140355846 422442356 114224816 249767986 184894286 608702280 290839540 397772225 300467410 669440864 292834691 668842291 637459705 989007424 336215565 262642723 354901606 425615693 140395151…
Output: 17798732444

Example 2:

Input: 258 75 667782096 346602496 236228976 612927305 345012306 585403737 386514950 865333813 669137968 133232533 392430671 291342850 175221145 126065105 820377038 700290467 530623269 716384398 866102365 960231945 773421113 77792990 363773599 111603919 549874643 479793954 363214768 408080736 595746796 889555493 432077760 358052627 628345246 662852375 838455368 291271450 595397181 109398789 54399302 694812987 712703619 559329318 788674931 237890372 222826311 174686904 831333036 633069270 462904071 424431763 969066924 54664761 634882235 150438084 746338119 794984536 321072153 58891475 633896648 727437824 792837125 810442459 12096074 967765605 279461224 645370981 811007232 226346401 776280906 886639094 712641616 84951593 905332217 109080101 6943579 428743702 840967055 88459281 246759134 151543192 41…
Output: 40806305948

Example 3:

Input: 20 10 502534840 383499532 105459144 339353453 729875325 286504631 436731805 383179882 807394529 144533716 632382807 698142379 993630197 39772505 225671497 906456465 118221230 925634250 715594538 73963358
Output: 5491839575

Constraints:

1 <= k <= n <= 2969; -1000000 <= a[i] <= 1000000000.

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