CT39485

Kian Counts the ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the pine barrens of Needlepoint with crates of ribbons, and Kian the clerk 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 <= 1623; 1 <= a[i] <= 1000000.

Example 1:

Input: 546 475 169974 581533 326395 675015 356107 1088 494755 469077 279102 555419 7664 166893 572049 428321 68226 201263 246187 444558 555904 636567 763448 416129 151381 545307 311975 217403 246769 405783 300487 170919 489769 884955 937214 300158 592316 240947 212746 541071 847933 3775 168790 563750 9285 175169 196297 105899 859823 33230 403219 195218 516734 209358 204490 604002 463673 674855 942683 348528 569912 552699 588371 560848 611451 271890 948847 634015 224120 384221 268934 666973 782846 77438 694537 874362 197043 888710 907651 19666 430736 84760 564954 248638 112793 365743 451276 368751 791610 535837 996225 796858 233009 624942 493982 951763 87604 911880 659474 748849 210581 346624 249706 961691 301306 191910 710320 494443 887439 205334 203875 528474 623683 290212 501457 460958 756928 1…
Output: 236688974

Example 2:

Input: 336 99 492015 674448 487529 184560 388925 300561 875236 895850 101790 280230 779422 184004 153940 902567 823364 941320 644762 104414 354367 416677 969032 56132 206135 257830 389607 506714 611124 855979 100891 363272 393558 195 359223 686169 642006 280347 272297 104813 748407 890130 580449 311362 527090 74052 374928 358723 217974 803405 930587 69505 25374 413232 14510 746000 942576 479206 254020 924296 168242 202820 486176 276107 526175 197030 857636 894700 557279 211420 242108 146791 528238 20685 938405 219473 457473 923084 143728 229602 270027 858290 139663 676669 932308 64493 560085 200276 794634 464282 449195 337041 508154 11999 985200 25348 991502 48899 249690 619134 316823 372414 469646 471471 158341 464139 894415 697715 828181 525145 133232 625026 301834 685385 26545 266772 5191 8149…
Output: 42917706

Example 3:

Input: 302 127 894364 553650 402083 998805 757808 678589 882613 102951 284838 402743 426888 762593 616230 142570 408138 786358 915329 66002 35281 157568 624497 259873 740825 982578 775876 930172 509352 860347 695865 945935 614127 665697 77132 179634 927632 339758 320655 242027 798375 315487 634319 687009 387427 673955 765988 781082 922385 293926 332167 582105 15320 424704 257475 427892 94511 902745 852509 213328 550450 649688 227722 610682 538484 872687 712773 471393 19891 585172 763973 625625 523044 249946 447392 97696 34044 620409 624972 99245 646856 510132 1634 725294 582753 35442 951443 739053 69396 312711 80025 270513 887198 179556 67231 773006 742034 29349 954402 795478 85667 250879 410238 50505 505719 425290 616017 25921 818266 254227 436425 304809 114540 176282 105184 382522 978960 151548…
Output: 56498037

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Kian Counts the ribbons - MEDIUM Coding Problem | CodeTikki