1. 程式人生 > >CF467C George and Job

CF467C George and Job

col ans pre ++ clas -m style clu and

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;

const int N=5e3+5;

int n,m,k;
long long p[N];
long long sum[N];
long long dp[N][N];

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    
for(int i=1;i<=n;++i) { scanf("%lld",p+i); sum[i]=sum[i-1]+p[i]; } for(int i=m;i<=n;++i) { for(int j=1;j<=k;++j) { dp[i][j]=max(dp[i-1][j],dp[i-m][j-1]+sum[i]-sum[i-m]); } } int ans=-1; printf("%lld",dp[n][k]);
return 0; }

CF467C George and Job