CT43360

The Fixed Window Peak of the Northern segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the shale slopes of Greystone as Jessa unrolls the day's manifest of segments. The tally will decide the next shipment. 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 <= 2497; 0 <= a[i] <= 1000000.

Example 1:

Input: 922 534 92917 202737 166928 30730 103699 124981 231905 31737 817505 82835 839031 343207 853387 500223 317281 598972 415598 327563 605308 971526 510621 498263 786412 642503 728965 930416 610215 757286 913063 468180 461444 856802 622617 594528 274213 334319 272586 379004 546934 724889 364486 204063 584366 860531 957878 889821 391020 146528 438947 719235 279420 88285 682599 956879 408958 495511 519335 481517 473403 191805 593477 215316 610970 421622 55424 679634 971107 978046 496577 7514 889983 16013 217399 705651 125604 492549 63770 362456 71426 247149 133583 999469 978517 453651 468803 106978 183406 955296 8596 112204 708383 155055 263624 957492 360854 896766 444906 964285 616536 985368 899225 441377 215383 220923 834907 778634 993511 453480 431764 42851 146462 103384 104866 623302 39287 50…
Output: 285857703

Example 2:

Input: 1449 1421 415412 283963 809944 49577 559736 78594 956725 540377 717899 679635 234536 805068 337335 293617 238062 201514 917655 673210 387155 926379 992238 582752 839848 653447 95019 222584 244573 111934 575976 167658 835788 566412 146412 639294 369980 629807 724592 670410 168915 877358 905660 408888 653676 876622 914319 602822 38287 187196 182940 640868 955948 288344 585441 97511 388174 181939 88483 91576 702757 971422 157222 853420 181009 810458 804190 571921 944785 787068 905409 441023 323997 891112 507756 522240 408786 185414 9985 50920 142365 225646 416488 264000 471110 873161 638015 299132 449859 889934 105838 471462 552780 692967 81607 676580 400846 348357 273695 65218 167909 844482 126301 818649 610097 272766 231344 495282 592437 144154 312093 31901 946939 722958 518527 270056 28513…
Output: 697112397

Example 3:

Input: 130 13 480910 804517 767891 999955 898108 220712 724588 426968 308311 988632 75164 437506 828968 515058 605459 92627 325944 145911 422411 376865 56203 511508 972664 398195 14384 743025 952277 491540 374131 634654 772587 939390 615392 58139 820607 682454 662436 879770 638177 442212 54359 228957 489719 914634 121274 450266 484478 544970 523092 852580 764251 562877 954057 663933 933488 56036 280363 274681 409364 300770 475736 262278 903857 260247 6119 110152 790712 898363 426657 210203 48970 335844 946788 104453 191779 689768 342092 406357 728377 339663 700734 99836 729243 274229 994580 700903 10404 799609 595948 794073 109989 286576 677669 407751 537085 286494 360623 622537 499113 108371 33784 608517 210701 297209 592682 737064 706740 978933 762021 905112 144602 755360 795260 880479 532375 1…
Output: 8626402

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Fixed Window Peak of the Northern segments - MEDIUM Coding Problem | CodeTikki