标签:style blog http io ar color os sp java
5 2
5
3
4
2
10
9
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<stdlib.h> #include<algorithm> #define LL __int64 using namespace std; const int MAXN=2000+5; int a[MAXN],dp[MAXN][MAXN]; int main() { //freopen("in.txt","r",stdin); int n,m; scanf("%d %d",&n,&m); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=1;i<=n;i++) { dp[i][0]=dp[i-1][0]; for(int j=1;j<=m&&i-j>=0;j++) dp[i][0]=max(dp[i][0],max(dp[i-j][0],dp[i-j][j])); for(int k=1;k<=m;k++) dp[i][k]=dp[i-1][k-1]+a[i]; } printf("%d",dp[n][0]); return 0; }
标签:style blog http io ar color os sp java
原文地址:http://www.cnblogs.com/clliff/p/4116774.html