CT35090

The Caramel Fixed Window Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Quin inherited the shed at the trading post of Goldmeadow along with its curious bookkeeping system for ribbons. Time to make sense of it. 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 <= 3317; 0 <= a[i] <= 1000000000.

Example 1:

Input: 3072 2106 383621734 30111352 348378241 671585020 927304202 915529384 188716491 78594920 697910460 260641943 803416075 463325764 267022269 175578421 925935027 105436615 944820814 556975132 886496745 858721685 528209521 508039251 292411358 304083031 943800189 684350639 500198353 248074924 44783733 600977762 991242324 822530033 826118003 569554624 259818354 54805873 26541630 508430245 397124171 183232141 755231040 749622198 45287523 480952655 165822705 264008354 903617455 584406766 505016490 921188987 91796932 194542241 690548739 290427459 553392793 132664030 410555212 774019887 121419244 404807643 680792970 34174308 579202217 973453562 258194468 603117973 967145096 363755212 710978334 379016840 959258406 508893323 634194948 789272040 837605701 133675365 210697043 578526397 553570595 61034980…
Output: 1073823566555

Example 2:

Input: 2919 2390 390852514 82102363 442875926 740324646 287730717 391856933 586729553 956513617 299211559 464664924 704444233 276331478 837352854 307030205 738083292 649544684 663036125 191890415 647858285 622227872 47102370 185537409 135795742 778771013 431695681 241095593 106055286 419854018 739241876 749740480 199202940 696918682 831952423 137089697 39921090 211501759 893865896 615386546 857217360 77681013 513861528 597335799 506960497 397074282 603219407 994841876 914212394 454404707 324186336 7902609 815435565 739712605 753958619 866356953 429040052 80934215 53895013 935532595 285491114 177325797 95787239 938788378 607518821 285489624 953863742 472757754 504731501 325589869 750556781 758462069 583466930 729204794 725191473 363198763 961390730 61141250 948789839 399678948 695413240 175745130 …
Output: 1199977964205

Example 3:

Input: 1631 619 700287219 373833112 387886181 78191397 84446930 42758633 483552951 104857357 965923766 692833698 919791320 440629661 269493566 639381866 61179299 414192375 258754796 989355106 396617655 406697338 713046659 657015864 156239698 721160790 17015423 81375395 676246471 3026308 695556097 49472721 470872570 888067026 46002069 385877504 272803372 622296528 332920583 700834207 771521605 145875631 852724361 156251936 742418993 212464683 603500112 22436388 48769632 599654211 698312594 59609037 539099124 878928063 660204927 194704890 21842126 994893999 234045932 773429050 944901567 596278204 606952752 457551285 287031223 35714277 684194783 468457960 331231547 525159293 291072516 561155063 359110742 820441725 617956502 58873406 53055473 584832209 474833071 932699563 640980609 681393228 65007791…
Output: 316421489864

Constraints:

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

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