CT31862

Axel's Ledger of segments

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Axel found an old ledger of segments in the stall attic at the otter slides of Sleekwater. The margin notes pose a precise question. Task: Print the minimum sum of any contiguous subarray of length exactly k. Input format: First line: n and k. Second line: n integers. Output format: Print the minimum window sum. Constraints: 1 <= k <= n <= 3215; 1 <= a[i] <= 1000000.

Example 1:

Input: 20 5 693163 160306 143538 210865 205021 338470 499084 893129 935748 108552 402360 596050 824100 368188 125164 91830 322201 773297 346274 814879
Output: 1058200

Example 2:

Input: 62 27 127872 513327 971769 276027 668792 413787 190645 96728 320125 682479 534945 174723 913862 993289 886469 196460 102893 941152 634375 335334 963102 761247 495068 678266 122095 19774 572840 392706 65639 720682 333301 509236 305313 681711 626190 16376 300856 20272 28575 273751 195696 60589 826591 294788 350684 500598 634390 376195 354800 662487 140352 950512 168208 918218 578102 484496 995657 656305 123245 187265 120543 787654
Output: 9386487

Example 3:

Input: 1769 638 520301 377703 74111 34620 930439 75016 593723 946408 367345 698579 802555 549979 113512 843907 162804 614810 610710 935616 43700 700767 859080 269653 491336 365103 96557 633371 404802 619450 47409 243809 147444 820600 207165 716971 516757 261733 396149 877191 440169 31743 655526 868307 569126 481813 532582 960109 266189 895450 376978 261035 463437 138357 300636 730749 546095 548780 212474 612990 885984 266580 632100 798299 673715 621461 88757 526911 600256 386616 17134 421213 952320 312081 342315 94350 956402 961823 123082 976635 93817 597414 641750 810296 642569 489382 90665 891223 68862 82487 833111 51915 772613 919189 366325 950142 976777 708806 984675 388708 161976 118006 497189 718549 972243 986803 569814 917074 360350 951889 32468 345092 750976 597140 721740 134337 260944 78…
Output: 301614899

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Axel's Ledger of segments - MEDIUM Coding Problem | CodeTikki