CT55796

The windows at Needlepoint

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the pine barrens of Needlepoint with crates of windows, and Rekha the quartermaster must account for every last one. 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 <= 3520; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 404 100 245417 194125 -653481 -415951 -236281 -780631 -281777 -787383 987298 -158285 524257 410533 -278703 523962 -332469 -256764 466816 -483066 724376 766074 338781 393871 228365 -579740 280816 513778 -36140 -694949 -134822 631453 341652 552311 405017 -672298 529880 673899 -452694 965890 245887 -204898 -331031 85865 -329703 -444123 218347 -955974 12841 119762 620453 -910281 -791765 -789103 132066 208103 486852 303831 850095 -225425 -305502 -146940 393140 465229 211303 629838 -786762 -605926 506357 -266209 -381549 -591612 -266811 169712 716307 -790960 754966 -697242 -358417 351976 963366 710130 147442 -776813 415232 312666 539030 894681 440287 -300377 -489400 158590 -389523 105178 390183 990849 427576 752770 -726095 -500317 629415 -192256 54698 -750904 -6317 783050 -616904 585395 409529 -6…
Output: -9921185

Example 2:

Input: 1580 509 -325798 788635 102451 611096 500020 -9810 226445 -239640 -460845 -961227 -816534 -906986 185805 325876 997647 116629 614594 766084 -826170 -186197 -721211 923590 708224 -46011 -911397 132640 -297869 561651 379355 -677864 934081 175272 -473673 -344006 753054 -724276 789885 -126821 -346200 -514966 819635 -894870 -495115 -545458 -195184 -954124 -521791 -419019 606000 654038 716140 -734974 -151665 -945088 -166533 -447149 614545 141789 -654920 96224 385690 -262242 -106304 -30505 -510497 -405112 748915 -401083 632499 -984855 257896 -445527 -87629 163018 -156230 154012 341474 -845576 -47222 214852 -808933 30676 336697 376779 785708 491461 -992882 -336932 -495277 -977455 215676 999293 -630942 -336282 -237178 648547 33402 481668 -183391 -723675 -737475 737688 556923 -310191 -877037 -48571 …
Output: -1911626

Example 3:

Input: 67 41 501949 44633 65411 315710 564093 -996683 817681 -864439 -21533 535838 56355 -471764 -796446 779087 797136 -598880 -129100 -197179 970790 722092 -635203 394931 325310 756869 175618 -535844 -691562 -700272 47440 7366 -919349 616454 403811 733064 -651596 168672 298866 -357182 -760704 -906685 -100884 859177 -594276 -614437 -544097 274522 312729 969634 979912 512766 208239 -752217 -214652 -597077 -209060 106991 335862 -316243 21979 212168 -944617 -978320 493602 -800598 170657 -548445 -865641
Output: -5334003

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The windows at Needlepoint - MEDIUM Coding Problem | CodeTikki