CT32289

Zaid's Northern scrolls

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The quartermaster Zaid has been asked to chart the migration season. On the desk lies a long table of scrolls readings. 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 <= 3439; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 3388 775 122369 999530 -813894 66572 -823649 -932332 -629004 591710 -827334 -778916 -113259 170014 -711222 -283288 13200 304928 999492 -610688 -50138 -724792 -396812 714053 612549 984176 -610744 -926548 276948 794230 -708696 365412 -636898 281960 559263 307070 489456 851070 -72281 738093 979053 693404 299329 -812621 -890321 -646586 -144072 -379145 -696891 955570 -974253 -815421 -150474 -900926 -628975 609091 110650 -691503 384250 749449 -240090 414578 272490 -204750 -159043 -931995 801660 -732548 136374 73591 -767949 -569899 -353186 -987594 231892 105360 -35363 504565 405847 339398 646292 94404 -658936 965514 236329 -476603 492470 -380298 -157752 635071 336689 -855657 731293 -911014 -522865 -560608 -880022 515173 -577532 204376 -698400 975205 113395 75518 -373807 -154912 314774 892314 -494…
Output: 37290843

Example 2:

Input: 2845 883 -898423 -466447 368696 61745 -162949 -920024 -914554 115249 -775615 -382146 55980 -108914 799759 -190895 -82494 537317 722680 -412197 259147 -44010 -810567 -357357 -603756 -968381 360119 739305 -273536 777521 -848658 -600964 227593 -848904 84758 968510 -632927 625074 -988472 392937 -176569 -128003 -340038 -26032 734203 597488 -195494 -527013 322610 -634489 856225 828292 509939 -612641 268728 -406658 -913026 -945554 -200392 -518153 -24317 -865569 -92164 991892 149562 -606700 254946 -829896 -448208 369829 208321 853033 -38587 920697 -189400 276263 424 540701 -3144 288740 -836478 -63235 -317790 98806 -367627 4783 953290 -688598 387564 892497 -531098 874545 -53156 809583 263609 825441 578488 921232 983202 -128231 -331711 160775 391182 -369150 -502098 268927 245480 -106359 106496 -2193…
Output: 43496049

Example 3:

Input: 3271 1226 -506278 -598969 5396 177160 -262395 -296954 390041 107703 273778 -51304 367694 430914 107112 -154189 -652343 -923931 -98698 122387 369870 825206 -999763 380114 681264 -585844 326270 -850914 673758 939756 277068 295042 636218 -611112 -875507 53708 -285158 325898 647189 -327130 500587 139682 -24245 551192 -449468 -513132 137139 -64678 623212 -426407 -740378 -713994 162033 -422154 -619480 -641246 -379835 61539 726324 74696 320350 -364858 -445045 711017 747925 736910 -616143 806079 -935763 -78747 -363620 174022 -29472 -787943 -513941 127352 536410 -154764 -374837 690207 959429 234408 -783056 38740 -711773 56424 -420404 450172 -540730 -941865 527224 440484 -563683 -924895 -232096 968021 260697 -474743 861106 279530 427607 919141 -325987 176633 463683 -538468 597685 196811 377670 -6809…
Output: 30290587

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Zaid's Northern scrolls - MEDIUM Coding Problem | CodeTikki