CT34311

Rhys's Ledger of scrolls

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Rhys the reckoner watches over the coastal hub of Tidewater's stores of scrolls. A careful computation stands between order and chaos. 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 <= 3094; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 1621 721 868979 -445023 349478 963073 -318458 -218135 -201673 -728074 -410105 -58910 -761375 -996021 335180 488883 -411374 -526562 806839 -572273 -563653 880303 -972904 -394226 -371310 -672073 -197512 699202 404520 -63695 -973264 684475 -664498 -266420 156815 -430463 -46413 900024 -3590 -374936 -37718 -173587 -464300 -31567 543800 -266273 -245867 801678 190268 -890876 -998213 -35965 -988085 88218 983943 -94091 719315 174044 -68805 -349743 401093 205146 -718001 -933938 -886105 -213469 -843832 -648661 -938141 215586 -251845 843392 974904 604928 -253777 600488 803832 952961 7235 -352706 417653 825256 -220671 -223387 -642224 -822715 -7876 -548487 283420 -915934 28507 -109331 339613 891674 -545206 863205 -367342 153368 -831500 -45220 554909 -256421 -649462 -489438 -764451 345922 608253 691965 5…
Output: -13752111

Example 2:

Input: 32 23 902631 680156 820735 -45746 320463 -788071 100844 -579173 -513781 653887 -285597 -543752 -423454 94978 -950621 685799 -523853 -251972 -760089 932828 -595766 -69045 47175 -469573 -812232 886433 628317 824417 -193488 -153574 -674372 -198075
Output: -3956016

Example 3:

Input: 469 276 -818126 53758 -341433 462487 370473 289997 450719 -143751 876913 -849017 850244 33311 453076 -697130 653238 648624 914283 -323991 614604 673095 -713997 -748238 -461086 670777 -482367 296034 -922622 -342947 119709 -528310 -586841 345011 623906 363848 189404 176764 -184326 -726127 -432012 -17179 -957846 -383822 -684011 269013 996325 54620 426555 -63547 676285 878971 -380768 532736 842595 -916811 403506 920274 500817 421352 927002 -377560 91027 291680 740563 -579469 -847731 905853 -769098 241134 355065 -50499 -890186 -764708 -931315 649837 563413 -65043 155704 -613555 -480995 987226 363325 345327 492076 -643829 -159164 57720 -602556 -766949 -723272 323573 47788 848469 -989574 -601440 730929 182165 512403 677469 760029 -893933 322801 -739211 -549992 -712450 922402 636199 -21378 -315542…
Output: -6490334

Constraints:

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

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