CT43120

Vigo and the Amber segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the floating docks of Skyharbor, Vigo records each segments 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 <= 3142; 0 <= a[i] <= 1000000.

Example 1:

Input: 1687 1378 256060 381217 279467 994890 98009 752814 780035 529375 372964 123963 325381 311154 759148 437680 578290 939484 547444 542018 868240 827736 525105 84836 476571 78495 732459 629330 437397 386952 806868 393754 348984 478909 924168 147706 100632 230231 537781 886329 161240 997875 753075 866934 644342 214144 842159 767369 36289 400628 804404 466246 684365 861740 378885 3633 486159 543692 732271 565964 777652 877555 674185 705169 879037 879712 757400 313889 267119 363452 421536 217305 919482 957148 730141 390907 76258 724245 945455 406598 823863 185044 633928 4474 857797 923731 475020 481906 609663 486322 641773 842785 555824 365408 5389 877714 366848 498875 448722 944414 516855 890389 999586 774527 135216 345340 13917 929594 469002 246168 699114 699577 637972 911996 783715 571706 6688…
Output: 691697140

Example 2:

Input: 2657 1292 580700 356648 707712 845978 454298 756752 566760 794892 616954 685955 198486 396495 192775 532329 831218 209389 644494 524922 395072 492644 82744 57776 908935 986401 465933 581553 482088 849818 315370 729382 974227 906445 577251 171203 761995 390586 34152 650313 71646 560560 624957 970911 168785 98834 835999 281486 89929 311652 409531 922954 614050 949190 42798 459431 724922 300398 494593 609316 721814 194916 834013 397561 473396 367240 403400 816053 85934 674702 836881 194662 484693 534287 853066 463024 761475 309345 502060 940349 348270 730959 592029 264585 502837 184759 28775 376039 94385 31202 893766 514041 594793 558546 391474 857427 193411 975823 289748 137503 309109 850357 433527 798640 254563 156054 758033 152607 1813 332007 417853 902645 444342 783399 277094 837539 75974…
Output: 635192916

Example 3:

Input: 361 172 333055 144144 639861 255896 812158 907048 517701 421219 81451 36849 43084 162802 283133 797027 64344 72137 859546 613153 90504 930074 69627 231228 822424 295713 191782 131328 698182 708241 402578 143109 769662 3353 329640 630353 333190 465049 598182 237440 316388 785051 403929 890598 278152 768350 240685 59519 106126 897289 27221 904001 60811 191916 898314 98882 550355 31132 676931 558582 982091 725682 849370 52159 41458 409055 390360 860809 669331 412047 698914 940707 42853 901909 758846 569062 175315 925273 651471 624984 436463 819256 495007 141188 565867 644092 699406 405212 988502 853025 603183 471687 996268 317929 531202 144148 689215 285183 742675 86815 436284 105822 831748 934656 613872 252190 280966 281341 179613 10600 230272 818486 771444 86550 195430 813572 838388 3568 90…
Output: 78190516

Constraints:

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

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