CT55090

Piper's ribbons Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the crystal caves of Luminar, Piper records each ribbons in a worn leather ledger. The guild wants answers, not guesses. 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 <= 1202; -1000000 <= a[i] <= 1000.

Example 1:

Input: 536 121 -740840 -60223 -516581 -516116 -798074 -204443 -597301 -249303 -323467 -129200 -182158 -941292 -707462 -262798 -498197 -921127 -38802 -456437 -182736 -919694 -540225 -197746 -89285 -509374 -631869 -415744 -591680 -294722 -619085 -662917 -611869 -622341 -635721 -61873 -216411 -980723 -24976 -95570 -106601 -565600 -373072 -535251 -265838 -14757 -379358 -167637 -197380 -674227 -680308 -283442 -857925 -396893 -690042 -148544 -924818 -231321 -779496 -326269 -433163 -810587 -22573 -953240 -45933 -259312 -750130 -647751 -638078 -866607 -212556 -582833 -295813 -303923 -361772 -59293 -640338 -721477 -75514 -808157 -874103 -74372 -676606 -895489 -29659 -338286 -419830 -998198 -364940 -406602 -688599 -936124 -954253 -233203 -558231 -294507 -411255 -355786 -3444 -914209 -462474 -501604 -981742…
Output: -66055528

Example 2:

Input: 498 185 -866284 -208068 -502552 -593042 -333848 -850774 -35931 -932954 -854658 -894150 -139826 -590325 -509992 -55836 -635958 -774845 -444548 -329757 -586133 -783383 -658010 -208366 -208493 881 -538027 -48204 -30467 -313398 -486607 -999967 -717411 -88 -712610 -641239 -475752 -285323 -369089 -785263 -401794 -867251 -531338 -29160 -826955 -355383 -398258 -707329 -103038 -75932 -436713 -245019 -197295 -930595 -413712 -862487 -265897 -733015 -865978 -847519 -635884 -995856 -453221 -763475 -347203 -308272 -287052 -454182 -490619 -31006 -508473 -876773 -931469 -486811 -317257 -783834 -956703 -323002 -698202 -275828 -62423 -567263 -798666 -81510 -371918 -996448 -135385 -56521 -362972 -849597 -650735 -868750 -549062 -810784 -561585 -849550 -193773 -796155 -15322 -112433 -591434 -350718 -572171 -22…
Output: -97034667

Example 3:

Input: 880 495 -92107 -875063 -386936 -612127 -335371 -626784 -215658 -11897 -470839 -85640 -232939 -933735 -292188 -786520 -67604 -221310 -360956 -422045 -847203 -853249 -702327 -600652 -90901 -159057 -199604 -737566 -433611 -597608 -840343 -482631 -776899 -423376 -758184 -302231 -861698 -868308 -533870 -915630 -358187 -141045 -521702 -628790 -418144 -199032 -625037 -799298 -231104 -43426 -367866 -909668 -732919 -948241 -881975 -751079 -98209 -213976 -832971 -640560 -719859 -550160 -45562 -858114 -49975 -452991 -172197 -596338 -192372 -417431 -522762 -165695 -655267 -820579 -469063 -715912 -592765 -890744 -760080 -87336 -602470 -342287 -373638 -774163 -500767 -482300 -160653 -622647 -328160 -701249 -509081 -528600 -996228 -470867 -293470 -358162 -444381 -823190 -336394 -823884 -780923 -810627 -8…
Output: -252008387

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Piper's ribbons Reckoning - MEDIUM Coding Problem | CodeTikki