CT51883

Fiora Counts the panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the tannery row of Leatherwick with crates of panels, and Fiora the bookkeeper 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 <= 1071; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 47 20 -913363 -438617 -377917 300733 -877857 -424250 -472352 56692 -196371 -36927 -536729 -230420 899773 598176 -576035 -834785 -925770 222449 413671 -242673 -731356 835943 150643 -639668 -908388 534346 506339 518561 588546 415632 175159 659036 -38288 171295 221760 897633 955288 -650426 707678 76377 -15902 -538695 -860052 -612980 -887347 -950632 -151083
Output: 5161564

Example 2:

Input: 937 915 -831755 -996321 -913006 -508671 -582340 900267 902712 674421 767073 479889 -839024 812321 392090 -458303 687579 660233 782095 633909 82259 -610278 187382 -968280 577370 399301 -99194 145157 727960 549395 -399688 -275835 599975 510736 -579864 881906 634002 -198905 -559311 48797 130511 348405 803761 -529347 -576 419683 -467289 355624 -601277 309432 -706139 -360218 -628856 102565 -952453 -102360 -630871 -362857 -616159 -493692 893477 334553 -703829 522444 295663 512519 637383 -362478 -571091 -267025 184881 -690840 -105436 -28387 781042 174537 24874 665331 926192 -259187 817388 -671453 -276852 -405706 504131 -191638 478025 -113733 -294655 -812519 -832436 70345 512346 -604633 143182 -695969 -891439 85763 641336 -294155 105074 -643256 605988 383199 -243552 -470689 -842615 197338 -754786 …
Output: 3488305

Example 3:

Input: 668 75 409230 976057 205903 -963255 904491 296603 688683 -339243 923865 -786269 448904 -376539 642831 -654085 -411683 236622 293372 987877 847960 841418 -939394 922204 675781 109328 -983082 261926 219630 -373257 650058 499104 -353997 582029 531694 -21339 848745 372826 291925 -254096 259748 -750002 435987 -839280 373240 90335 963263 680628 680232 872834 -919254 -303768 613324 725303 -410381 -744964 -204463 -175353 598435 -749640 575780 690999 574877 782697 -237084 913916 640260 542939 -910609 -668241 523137 -171108 -26507 -757381 40342 864105 -681262 165320 190324 303810 462514 769092 -380510 742163 -593505 684153 782727 43442 -987329 475329 635829 956388 -48256 -750820 -646487 557038 194639 -797102 223189 -898116 984141 418474 -923615 -110447 392750 -57933 716439 -289661 -516154 -658901 -2…
Output: 14390165

Constraints:

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

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