第二题暴力法过了45(超时),正常思路反而只有18什么鬼
import java.util.Scanner;
public class Main {
public static void main( String[] args ) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[] a = new int[n];
for(int i=0;i<n;i++) {
a[i] = sc.nextInt();
}
int res = 0;
if(m >= n) {
for(int i=0;i<n;i++) {
res += a[i];
}
System.out.println(res);
}else {
res = Integer.MAX_VALUE;
int[][] dp = new int[n+1][n+1];
for(int i=1;i<=n;i++) {
for(int j=i;j<=n;j++) {
dp[i][j] = dp[i][j-1] + a[j-1];
if(j - i + 1 >= m && dp[i][j] < res) {
res = dp[i][j];
}
}
}
System.out.println(res);
}
}
}