codeforces 467C George and Job dp
2014-09-23 16:24
399 查看
题目大意:n个数排成一列,在这n个数中取k段连续的长度为m的序列并最大化。
dp[i][j]表示前 i 个数中取 j 段的最大值。
dp[i][j]表示前 i 个数中取 j 段的最大值。
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; ll dp[5100][5100],sum[5100]; int n,m,k; int main() { scanf("%d%d%d",&n,&m,&k); int i,j,x; sum[0]=0; for(i=1;i<=n;i++) { scanf("%d",&x); sum[i]=sum[i-1]+x; } memset(dp,0,sizeof(dp)); for(i=m;i<=n;i++) for(j=1;j<=k;j++) dp[i][j]=max(dp[i-1][j],dp[i-m][j-1]+sum[i]-sum[i-m]); printf("%I64d\n",dp [k]); return 0; }
相关文章推荐
- Codeforces 467C George and Job(dp)
- Codeforces 467C George and Job(dp)
- Codeforces 467C George and Job(dp)
- Codeforces 467C George and Job(DP)
- Codeforces 467C George and Job(dp)
- codeforces 467C George and Job(简单dp,看了题解抄一遍)
- codeforces 467C George and Job dp
- Codeforces 467C George and Job DP
- Codeforces 467C George and Job(动态规划)
- codeforces 467CGeorge and Job
- Codeforces Round #267 (Div. 2)467C George and Job(dp)
- CodeForces - 467C George and Job
- Codeforces 467C. George and Job
- 【CF】 467C George and Job DP
- 【CF】 467C George and Job DP
- Codeforces 467C. George and Job (dp)
- Codeforces Round #267 (Div. 2) C. George and Job DP
- [CodeForces 467C]George and Job[DP]
- cf_467C_George and Job
- codeforces-467C-George and Job【dp】