CT35596

The ribbons Calm Window Puzzle

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Tara found an old ledger of ribbons in the ferry office attic at the galleon yard of Masthead. The margin notes pose a precise question. 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 <= 2767; 0 <= a[i] <= 1000000000.

Example 1:

Input: 1886 329 770542618 272413578 542247124 897002196 199965785 414007327 440360222 983722481 539843607 438200671 289205736 781666070 950710661 273806095 960867539 155989132 191940815 620823951 241043734 803241255 756362938 619922472 153644741 615731389 396864726 387237003 20409156 880451386 690698979 234758782 254791890 301700528 614242740 358027142 463821705 831398376 389266118 612922960 573059844 198883688 826459912 585128206 94435180 573444600 248018191 418016288 768420100 444156048 829559868 318121216 100942676 808915660 380429414 574137661 329931846 65054533 564359115 210383641 847859179 118208510 44427811 608830800 596207550 833672738 959989881 261612880 860387591 439560427 253139928 285491110 711334375 13700037 565232933 507797321 554137191 627676424 204369626 835667854 216244297 987896…
Output: 155578212285

Example 2:

Input: 1623 1106 988933104 84345779 977244620 119837447 533913745 988116290 971206577 781170870 19796945 4816594 132923235 850676693 394139528 26525459 221964004 229351059 105068165 841480793 858226951 697145940 402832835 758334688 218042494 214129749 803946575 239166093 473538620 716849787 335263040 145781170 667922384 122482361 893426418 857648485 559720848 955862991 716773517 770296889 662792946 621094123 146307526 5519150 810444962 56202364 554039792 712530580 397518980 99136015 711170931 123526300 179808193 150660027 628414961 628320506 300817027 708927742 421475426 170925937 915250361 346517896 173917344 791748092 943826097 619006801 203893612 43575965 13594210 256459835 88734317 358372900 117537232 637089388 541225645 223641798 403464060 486507682 511759904 107345303 403242961 411823463 55…
Output: 550057522988

Example 3:

Input: 1905 608 300005179 630087410 597587879 861584725 703452952 136676070 687824570 652453305 525907456 349610822 533002982 245767883 306817624 808876120 577459564 324389478 339154670 656689792 709009150 317433085 794073553 2665874 713010555 834188551 909870220 741580654 820149992 325604500 802040668 625566870 355668894 810519355 111487223 789180933 549713167 707261023 378729323 608414276 483167043 337248830 950442453 992886054 86876129 525347735 618939225 510175263 57647898 394241722 149874046 64996380 973902160 258194904 91243000 746625661 518194678 340682232 657830104 694122993 600391516 356642292 169837547 637395241 582075276 984103862 473746616 395997952 537158537 767511405 47917310 414355982 583934094 265510359 654158613 532592026 773361958 234724774 138932587 736483268 395247856 58564611…
Output: 293282959400

Constraints:

1 <= k <= n <= 2767; 0 <= a[i] <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
The ribbons Calm Window Puzzle - MEDIUM Coding Problem | CodeTikki