#include #include #include using namespace std; int main(){ int n,m; scanf("%d%d", &n,&m); vector w(n); for(int& x:w) scanf("%d", &x); if(m<=1){ printf("%d\n", 0); return 0; } if(n==m){ printf("%d\n", accumulate(w.begin(), w.end(), 0)); return 0; } const int inf = 100000000; /* vector> dp(4, vector(m+2, -inf)); vector> dp_(4, vector(m+2, -inf)); dp[0][0] = 0; dp[3][1] = 0; for(int i=1; i> dp(m+2, vector(4, -inf)); vector> dp_(m+2, vector(4, -inf)); dp[0][0] = 0; dp[1][3] = 0; for(int i=1; i