题目链接:https://www.tyvj.cn/Problem_Show.aspx?id=1023
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;
int a[],f[][];
int main(void)
{
//freopen("in1.txt","r",stdin);
int n, m; scanf("%d%d",&n,&m); for(int i=;i<=n;scanf("%d",a+i++)); f[][]=,f[][]=a[];
for(int i=;i<=n;++i)
for(int j=;j<=m;++j) {
if(!j) for(int k=;k<=i;++k)
f[i][]=max(max(f[i-][],f[i-k][k]),f[i][]);
else f[i][j]=f[i-][j-]+a[i];
//printf("%d ",f[i][j]);
}
printf("\n%d\n",f[n][]);
return ;
}
=_=