CT32642

Wren Counts the segments

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Wren found an old ledger of segments in the loft attic at the zephyr cliffs of Galeholm. 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 <= 1945; 0 <= a[i] <= 1000000000.

Example 1:

Input: 1620 1119 595236430 680589851 284394052 420401896 234830253 578617410 835880334 105242459 195832903 656738745 711814922 632110013 221839168 319333018 13396918 222985150 337185045 840831781 167491030 357716526 664114162 93425227 490487030 249742287 835307866 107288782 16076289 350523012 334357530 375670529 887068330 569238633 224503626 595545187 491309616 725908458 94411529 347535046 445955069 147318148 47784239 602296281 23262320 771223808 682377999 705051850 374167775 521833169 381083747 708499178 861029537 404221398 111401574 268470402 227904372 501850990 82587964 654751962 956992333 936395652 239925487 9419047 290016658 854819867 660449743 595856532 28176035 662764896 199751323 203331757 826551531 497512072 411007891 794219723 654678138 190702241 91508778 43507323 878264812 928977311 78…
Output: 548578332019

Example 2:

Input: 645 337 710457929 157357954 471548917 498481186 36021106 687007410 125398679 585584651 110671734 727022300 126035996 863319336 446714525 453401391 479064522 806007232 352977132 211475510 277042171 877116186 545901991 283555071 778362533 242661952 970137292 763713459 330072923 226986428 77478730 740413064 274165719 692456719 351235094 920689995 656785937 304029854 467030139 132039662 547040049 740510385 309716003 351322245 92891164 345970604 946464592 860985588 32806753 371829884 324658650 434599972 566329564 886861566 352172569 258947753 924805751 253349884 803535812 35060789 86402502 233845493 301566165 874323104 559707341 11831900 498626760 823004321 251132994 654895795 347848650 756785716 893923578 547281935 302637100 355234657 813922598 778377954 767256217 899841913 657807012 638133736…
Output: 165188675429

Example 3:

Input: 1274 423 265279724 439489416 244040492 499531760 98168598 106754906 445783608 510080512 912046987 26778892 588229086 525123260 208038533 812558030 523122650 618722068 31751108 480313538 877214233 363014664 533147322 803944540 27607501 997373955 379181849 956293890 449098130 905890277 117209847 11019002 613019094 818576806 510525524 865482950 350156443 39344948 782242976 483961284 355985348 412853147 923542078 246920877 512979751 457986086 932818428 189792844 780619281 679669358 72298087 710902246 915829813 764626530 1373681 335614270 655379826 59020260 734953876 218826175 486692910 103640184 921855181 304253903 331123071 640975794 940971059 91486532 16568931 649692580 309134763 55131511 499077647 573872892 48530963 934518074 336295557 233080761 793475392 419584522 521266826 151933698 82520…
Output: 204806435837

Constraints:

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

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