第一题不会 第二题 public class Two {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[] nums = new int[n+1];
for (int i = 1; i <= n; i++) {
nums[i] = sc.nextInt();
}
int ans = 0;
int[] sum = new int[n+1];
for (int i = 1; i <=n ; i++) {
sum[i] = sum[i-1]+nums[i];
}
int[] dp = new int[n+1];
for (int i = m; i <=n ; i++) {
dp[i] = Math.min(dp[i-1],sum[i-1]-sum[i-m])+nums[i];
ans = Math.min(ans,dp[i]);
}
System.out.println(ans);
}
}