CT47695

The Crosswater Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the ferry landing of Crosswater with crates of segments, and Devi the reckoner 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 <= 1960; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1376 108 973512161 977204037 640591564 248058330 177642491 230917671 971786834 313155128 508750946 409962685 483854723 9916947 705679063 648530078 186443432 359560142 166556564 766643621 261289896 905539140 383080500 208301393 286542972 614131984 439933636 658859170 132050456 584097074 355347048 850729517 4013611 539234362 501876105 703814102 780623421 179938422 404241167 302354710 316811249 206076573 896214433 322337086 181161707 156918843 931193718 584558492 202889451 852458401 137992624 977141650 582875363 205165605 502799346 173090895 535051494 568864047 874103103 364186288 888718333 672529018 479462659 671463986 970326840 439611292 837006235 349543841 971819685 450497741 185800159 751003396 776067783 382431663 337612016 40369062 605608777 800909449 393653024 942884265 421270882 132506…
Output: 62923649600

Example 2:

Input: 545 282 14261541 446904078 55982562 808460925 775293405 25773694 847399512 602308646 421465421 624684197 839750770 121229519 990510970 74621879 71657451 324983586 474522476 894312214 700093527 227523810 420108119 417174417 151221794 167087391 588666786 662556938 594647010 273437397 191530722 793331227 912745992 654933363 693446605 557606742 796453886 549117399 356412760 251243509 809926719 476045205 872367427 206866761 108940184 746056640 251890412 710693329 80516757 758701771 344284262 954139780 690904152 50232025 641232095 802702900 15807087 59272600 968605968 122949769 267196762 278767510 936137637 74585465 700210079 805308476 470097247 49199527 833641881 302415819 586123184 362116003 498109188 234488802 570002713 980535067 830185891 361644733 922824179 865247464 622992525 62128715 3527…
Output: 140772807281

Example 3:

Input: 388 150 297698723 675664780 431045415 837211939 30880706 90978764 531286819 708769854 835564561 57158458 179325917 116157900 360456318 313273791 743377619 148147472 208412733 370160939 862665004 9480422 362991847 567934170 101843700 280000719 541302252 949088467 585707619 676571999 531161831 978971912 193348224 944271349 42956299 563841781 554179001 72963816 472772982 877143228 436511353 966397967 55084043 66873282 817999436 285734966 649140972 933758833 318955319 842501970 974289669 254962484 838869470 20759347 566621524 314323875 270966384 221797695 486609817 553039815 455514542 704423637 926622621 186070240 87602101 342755496 906111761 769029140 99080309 782548679 311380172 529004517 487813574 443807354 898330862 206475487 887082151 170803544 873359715 735658565 834931277 166762717 2205…
Output: 79128902449

Constraints:

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

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