CT46727

The Fixed Window Peak at Deepwater

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the fjord village of Deepwater, Warden studies rows of panels entries. One clean number will settle the guild's oldest argument. 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 <= 1361; 1 <= a[i] <= 1000000.

Example 1:

Input: 456 99 173602 80389 254140 541295 618601 41287 419254 527389 946302 254467 835557 430882 491603 517253 811652 48485 699410 747752 654718 68984 427279 428276 310612 336170 259924 219060 837787 584596 291895 871496 538808 570840 69791 240226 875106 604846 56437 806856 470011 199083 629246 98746 315762 536274 629041 340371 332712 435213 508586 706819 787464 270470 562875 976136 517702 953613 807995 840770 943852 340598 343100 625422 22786 894162 164548 768551 635619 5666 111045 718523 722380 893038 478305 784081 887449 889835 999042 681102 978917 998407 2136 776382 152615 462046 4335 999660 419240 59330 936174 95893 550129 487846 24952 11783 765069 635699 194140 167473 557277 745138 333478 838860 303 75473 812907 791323 856742 808132 822625 672631 26522 164468 682417 551509 301263 295357 7963…
Output: 54198305

Example 2:

Input: 428 90 995027 500891 111364 514567 122703 967289 796691 419926 872036 722290 379865 877008 900025 263326 622759 160033 705603 625789 179065 211455 664540 975423 471758 797914 65048 344037 688034 483036 271332 750260 235018 264550 279109 948579 930931 12476 343947 284898 760499 445461 677113 596563 285247 295427 618979 274944 149502 484908 338300 922040 520727 347643 148672 721375 206524 893502 174722 488644 472267 661381 550423 830653 494345 977342 411693 751974 955241 52742 432328 466356 321228 436291 799744 669409 737226 422776 688633 969273 716115 419420 943326 738954 930073 253265 740996 114605 277934 518877 429148 872983 233145 283977 332651 678319 167640 745439 38073 344057 358075 977253 923358 512828 520092 100458 444991 543199 637347 431948 496624 582896 187537 721693 446297 430942…
Output: 49252155

Example 3:

Input: 1011 64 331172 699534 708590 334569 126574 535604 305715 812599 203582 147023 683776 978791 636410 701822 565851 342013 457094 66980 779741 251484 266474 87662 40459 369832 712660 526462 309471 829189 372912 803226 676190 315700 907064 249363 410542 373414 764832 127420 104067 73097 39728 581430 739149 932821 836846 445729 730999 719510 704664 968228 746454 519321 862105 580320 79883 931665 417687 479246 59415 39513 692467 348094 377491 31510 280559 830163 744628 854063 137050 634778 771985 678532 468821 378101 301184 920881 313235 715119 128821 317274 162197 77777 790595 326938 741769 876291 38556 446508 297791 452788 253044 247960 825050 874510 932765 534144 928695 451244 760424 517034 462741 932277 352604 569655 594828 585344 695588 475429 906450 928189 556750 857824 30448 183376 822328…
Output: 40005098

Constraints:

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

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