显示代码纯文本
//Orz HXF dalao
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int n,m,d[10010],f[510][10010]={0};
int main()
{
freopen("cowrun.in","r",stdin);
freopen("cowrun.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i)
{
scanf("%d",&d[i]);
}
for(int i=1;i<=n;++i)
{
f[0][i]=f[0][i-1];
for(int j=1;j<=min(i,m);++j)
{
f[0][i]=max(f[0][i],f[j][i-j]);
}
for(int j=1;j<=min(i,m);++j)
{
f[j][i]=f[j-1][i-1]+d[i];
}
}
printf("%d\n",f[0][n]);
return 0;
}