CT50650

The Calm Window Beneath Slitherwick

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the eel marshes of Slitherwick as Sage unrolls the day's manifest of ribbons. The tally will decide the next shipment. 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 <= 3288; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 644 638 -930300 871343 707564 -79188 -630180 -314366 426083 169137 966743 -214465 -149244 -728491 735481 -710447 443678 178352 -836167 867816 326387 200765 228744 197710 500172 653250 -887028 -556301 -932818 -683177 -690159 -156329 -754068 203264 -479871 -52313 -995724 455664 91044 -958956 409911 -223169 -336946 -788262 -542859 -572018 -994481 -158260 241227 -873789 -976812 354853 376918 -52301 186069 857556 -273177 311996 407176 891836 -402862 -212871 -405260 454424 711661 -782979 -659677 36642 605860 664309 -300734 763976 -98500 315792 -49335 -966769 -110851 -598172 175358 -395312 512069 -328318 639297 193424 -150892 749186 -379050 -295477 259671 997705 -884214 -669766 -388103 -276050 -809544 869719 312743 207640 940016 75811 254866 848204 637524 370840 713755 -83289 166414 583789 677926…
Output: -1933086

Example 2:

Input: 2049 1603 250000 -364000 -421996 -496618 652340 -992548 -80712 364293 -122307 369988 996235 -78314 763956 41258 -999099 948602 299480 -853552 190294 -842642 -69258 423580 900715 -875113 -267613 965249 -214900 896542 167896 -860756 565174 -864104 -214770 581780 939518 886771 808232 -970556 -708311 434860 264438 400598 -875250 482150 319504 -495690 713801 -944135 761021 -772885 -499317 -827087 -27500 -944983 -659417 992408 -875504 -447980 586764 687148 -715628 445652 183282 -742028 -646166 437479 519868 -763603 -996412 978888 -438092 828078 -818589 -772334 -170857 151770 662201 -916696 -76738 758392 -853208 55018 -177124 59976 -363674 316619 -902607 942860 -519036 898216 234770 -105865 526049 -802278 -625406 76418 -599604 817623 542621 -50498 778262 -271473 464846 -312828 172848 -358733 8837…
Output: -56744849

Example 3:

Input: 2812 1061 50855 -144509 -377491 612218 -445343 331233 246718 -774257 769673 -740387 651039 512719 977066 841389 -158139 506776 53131 650928 -509423 515271 728690 306169 -291906 -264786 -737592 -371376 -386544 -468621 -572466 -297851 480542 227120 259832 -331654 158669 644615 -185861 218315 -712677 -216505 930981 -678882 -452519 499392 2180 274391 8596 207157 30512 602189 972128 943579 368111 159304 809175 592394 223260 713809 675627 -472424 414943 137275 -243534 513054 -400377 469783 -931995 -559421 -261246 224493 35819 -902036 -637876 -658180 -627047 -488942 876020 -894259 -477869 932123 622878 63848 -573472 808882 171137 -998413 7903 929175 -41671 -757711 179588 -3405 749382 566996 393790 -42199 242727 -471566 -652190 -606848 -327013 -792994 -674293 75238 355884 181418 -845167 -445943 15…
Output: -22987468

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.