CT56431

The Fixed Window Peak at Argentium

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the marble forum of Argentium with crates of panels, and Iris the registry keeper 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 <= 3433; 0 <= a[i] <= 1000000.

Example 1:

Input: 2555 2118 595553 131059 927209 741576 815112 261009 792057 481662 353126 299104 522795 163948 600588 807278 987513 784145 89314 82417 301334 946443 780290 179633 744476 450885 646346 921100 294897 387388 236538 97844 602592 893555 910230 841242 65301 379531 28858 670446 765532 478744 230357 745933 687947 487042 919303 836934 594460 104827 261216 347476 283135 772342 951538 865938 24864 296136 723013 416191 680651 119012 966642 519254 583510 884764 65408 993042 940575 179640 66157 99599 694903 695055 305860 54884 397630 28544 965824 395368 265118 702969 281617 104581 488079 161878 700547 952074 803635 910151 528399 122754 82422 926611 35030 188582 844970 213469 589975 25634 330665 742906 176957 405744 312900 518792 469941 390995 996459 29141 642423 62220 993320 40517 524616 558884 464186 58…
Output: 1059950422

Example 2:

Input: 337 301 198606 730443 135244 23289 468037 752886 482227 882713 647712 353532 234422 207662 452379 101895 981598 2237 382268 906446 940593 833313 486508 222647 401225 781845 718334 716155 752289 458958 579406 258121 71990 579315 133589 256275 294237 681627 314167 728099 340310 323340 955997 842267 420856 807793 369898 48993 503181 611284 439759 388008 882396 328348 403526 985602 242662 401514 45160 845466 447383 786714 838618 741716 928207 919556 720387 966671 928300 315935 379882 601742 575967 308012 158803 333481 938384 661999 724272 745356 492748 386742 805996 89833 330211 594195 705543 249289 182351 749362 515149 508307 526822 277712 638708 489206 730212 980341 496929 257563 279141 505783 522208 519403 719260 613946 831683 425848 415646 480071 375397 323140 300672 643481 825595 121952 1…
Output: 155881022

Example 3:

Input: 1637 645 966564 520535 456263 132938 977521 393595 603389 389179 547361 696042 729141 924511 49702 417258 850479 957841 432408 640139 443054 654137 411424 972623 50537 853738 948456 62351 261778 391578 165841 899279 662940 773600 635779 404373 151624 774793 983502 288519 845640 296332 606744 750845 893233 281709 811143 647224 317506 34534 691042 378317 880640 13400 805019 496666 528147 572345 343946 881380 355390 455367 679993 996827 317857 833455 493327 900712 402097 44785 293641 593713 877273 617414 153457 613538 666582 734170 655290 630760 671379 200993 737591 931598 799064 550019 847098 304324 99114 330597 528890 162538 222077 936582 810518 173299 602778 969861 396296 650493 341646 277064 271226 984510 489295 585782 982249 154765 800109 551213 82767 835695 431133 3897 964393 741674 220…
Output: 328527468

Constraints:

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

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