CT48811

The Calm Window at Rustwood

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the fox den of Rustwood opens only for a perfect tally of scrolls. Jaya means to find out. 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 <= 2995; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1974 286 -104448 -708140 -307773 -157834 -666042 -469157 -773802 -214708 -532090 -144391 -379236 -319507 -476077 -649544 -825384 -707935 -252897 -248081 -230683 -646737 -758717 -503591 -42197 -933357 -478579 -954179 -92155 -309759 -439603 -554832 -286549 -985792 -64118 -585812 -896984 -921137 -260510 -56562 -36826 -882700 -765811 -31657 -327100 -192708 -920990 -401902 -17849 -7061 -352790 -735561 -584133 -57602 -888580 -580012 -384837 -586649 -361951 -420397 -529513 -131405 -84997 -700620 -156496 -791779 -709403 -97877 -313037 -845882 -200459 -605602 -982775 -69836 -161446 -178380 -568223 -826210 -11071 -984051 -377926 -27218 -917315 -188742 -574953 -466476 -700032 -632448 -839862 -966190 -569716 -95829 -601805 -937928 -626329 -646937 -49097 -173595 -775141 -399780 -763432 -478631 -905511 …
Output: -156369956

Example 2:

Input: 2667 114 -453143 -659423 -107106 -54790 -19697 -924847 -713854 -15004 -136452 -625184 -539212 -949993 -84450 -93721 -838717 -849189 -533809 -357799 -301138 -863084 -687279 -952961 -874823 -720454 -60266 -500865 -564001 -4019 -260329 -198882 -266647 -654641 -667673 -72418 -77403 -781531 -737507 -674281 -722879 -719638 -312430 -20427 -651233 -401813 -884162 -192394 -151952 -186586 -985213 -544469 -243261 -93483 -314425 -746849 -20188 -105951 -247796 -357743 -634694 -601352 -617390 -116074 -919947 -787585 -245160 -752077 -391343 -266087 -97050 -251617 -75208 -314319 -507468 -184547 -804742 -373784 -766741 -761549 -720910 -450458 -305422 -294179 -336652 -197515 -309296 -658581 -785596 -789226 -941516 -721244 -471845 -215264 -35306 -877904 -520295 -160075 -693258 -302565 -261233 -985762 -284497…
Output: -63402716

Example 3:

Input: 587 472 -152059 -86583 -185929 -357155 -718385 -642892 -856509 -48219 -125754 -201847 -610129 -552323 -244901 -397466 -668450 -834464 -761334 -860220 -298157 -986640 -364009 -905386 -46110 -404823 -312899 -424231 -25428 -819332 -415589 -54904 -558134 -878967 -981931 -847188 -808950 -531430 -325761 -822149 -552021 -858272 -101232 -126824 -72115 -530445 -203388 -232665 -367935 -464609 -571286 -550165 -43476 -524386 -943276 -747225 -426768 -205134 -735291 -83015 -891406 -629976 -100101 -87950 -433355 -127813 -114763 -686623 -52847 -695918 -65212 -357087 -141600 -539308 -140199 -803189 -409999 -878871 -558993 -852127 -266561 -855393 -520909 -937447 -847935 -726278 -19594 -81520 -577564 -293644 -21879 -399453 -637427 -206722 -928867 -253201 -75753 -500988 -889710 -473582 -860813 -556395 -489440…
Output: -243862088

Constraints:

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

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