CT51607

Diya's stretches Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the trading post of Goldmeadow, Diya records each stretches in a worn leather ledger. The guild wants answers, not guesses. 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 <= 1816; 0 <= a[i] <= 1000000000.

Example 1:

Input: 691 318 632580628 187538904 569508645 450641536 87654407 78903437 476344925 917242052 998020088 953157434 972209870 654467123 637253899 872495383 724402453 333184059 135132898 264247890 728385566 282412485 60142565 591377218 347346784 107613350 916942572 12017782 125563053 852481067 109054814 677473535 124168018 554138623 914235376 436805550 920540820 160273197 666862279 912460649 518136292 187990172 849840688 621454409 862241886 195510459 189511703 946015310 270618258 963213451 429408148 806207401 611616239 257790496 645922770 615687095 438680225 258634782 174374915 288235841 732605475 241977301 870502564 559772981 842411649 119866256 200101928 306017279 989134186 883565366 961370278 767997085 4969020 325607494 615483365 688040385 97238587 727231402 331127365 115908654 34019341 933590131 …
Output: 158892161197

Example 2:

Input: 993 42 221139931 503021677 69365786 859722412 476343206 57248579 86926388 126382796 746251476 155843353 107318497 225205962 326146027 300363083 449095082 364089170 386154266 266074147 916000526 974591496 655976204 362051594 331205967 966874007 912404301 124070214 955241224 512136399 809560602 178423671 934716434 768770832 893956300 374393632 782450806 815104225 140149204 135355332 685120328 55094570 277168544 543530246 901576941 232400177 797144354 164599695 44475760 645867228 628223808 456406962 138813903 379703665 595689191 604243901 216191630 555796221 144125992 546201731 143738938 96056773 394979806 817092588 866641073 802732635 873255383 546899209 15893833 842538148 601355202 197476769 986745095 535052668 241931303 725421651 127125705 950735626 73413579 150059068 706520081 358031832 5…
Output: 24566933962

Example 3:

Input: 1409 1333 884056856 53220464 298268260 293277385 831725881 818967445 468409726 394036857 832962183 754029960 718796495 238550167 305556795 892370701 529252301 58679152 268750705 549874330 938040671 314977652 153291980 639587143 624171345 915998870 394259509 255378972 48727440 54102409 839351240 247786764 757445053 6443170 874048140 731791218 679939319 294532812 74733609 374282638 371906630 169948228 934738135 501550569 678142912 879935580 848455566 344162473 91240429 359166141 671413432 838550029 175428196 841069834 400243800 309537373 944353333 427715262 844236311 815598119 577533545 875771795 179922334 761258929 758972677 610457874 361696184 24086058 765971594 889392296 896875466 984503243 736726776 764858203 74029125 519624391 513633964 860852333 81360766 320452781 747976420 563149728 3…
Output: 658177296022

Constraints:

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

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