CT41989

Lakshya's Fixed Window Peak Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the ribbon falls of Cascade Vale opens only for a perfect tally of scrolls. Lakshya means to find out. 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 <= 3945; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 318 60 808346466 947504797 151253780 666285160 420614081 771225675 257420892 644572216 196142183 965163315 33108864 765767512 630933766 564721977 398162524 450578737 45672410 343531012 318506197 960646844 74036054 715663742 26217454 787630577 283536393 452262594 719778526 159919502 758842829 788389591 166313252 891872535 841720281 392937391 31671114 59896580 764230189 286647095 338636213 852618104 666835670 223021040 223370996 76758129 807966597 141723764 888178210 404359814 889441701 656476799 301518063 31867487 372503874 624108984 377523189 897729196 145861701 241811455 439094846 598487993 195161484 909693102 478294394 192640140 209917841 712581784 329040270 839341540 455005129 256570394 498381498 161091552 823252654 37878119 295457601 590866203 260035231 143145008 358898110 396607787 62…
Output: 33785458031

Example 2:

Input: 2468 31 718997553 283229973 966206509 656777081 265947732 14015439 328612648 441583810 75579742 429618882 847441388 571983746 621661961 743357199 639715624 671050065 642632360 330651048 518197275 29207400 887002749 177217953 335572251 435675120 507389741 388951600 366746045 397373642 181904059 313849848 176321191 963988318 370865852 525468960 148510139 91514276 269502769 310764813 55695212 129073850 909303364 83249200 532578623 593372340 144909011 744356153 399802420 558624296 -778027 196649931 804502767 337994191 835733132 615194765 215945619 263769422 489696976 530515126 167852079 987659836 705414849 266293569 524666196 182243315 973044579 273267870 655096799 277373378 180403932 719991204 331573718 191793996 581909648 860844027 131805817 807847362 320147122 566418769 284025349 95825788 7…
Output: 19648534691

Example 3:

Input: 482 441 764231307 858876869 749179642 97603386 640015802 813945690 638567384 412463040 528709390 707277431 342192590 706926956 492323403 886999841 727765313 352141063 373328076 884761575 294071770 794552647 622553579 346814536 706174658 500011293 489107423 580461058 140327882 800726921 237876380 205096605 510862605 91666137 680119247 894006975 465982700 624009798 145372010 283547350 747285360 316700580 894058574 64769754 867173994 625758965 177289092 317004377 338465875 773988631 182280826 384797871 100996299 553649897 120720069 400733779 308890071 389182407 90696404 193922637 943358291 770089797 982255678 118088519 340745353 193335913 192892611 7285681 416779323 496518509 761458630 320484523 588081404 861759141 15734198 481200289 61735737 188152085 886971483 843949382 879657413 413057407 …
Output: 220298317596

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Lakshya's Fixed Window Peak Ledger - MEDIUM Coding Problem | CodeTikki