第二点五个不高兴的小明
作者:互联网
#include<iostream>
using namespace std;
const int N = 1010, INF = 0x3f3f3f3f;
int w[N];
int f[N][N];
int n, p, t;
int main(){
cin >> n >> p >> t;
for(int i = 1; i <= n; i ++) cin >> w[i];
//w[0] = 0;
for(int i = max(n - p, 0); i <= n; i ++) f[i][1] = w[i];
for(int i = n; i >= 0; i --)
for(int j = 2; j <= t; j ++){
f[i][j] = -INF;
for(int k = 1; k <= p && i + k <= n; k ++) f[i][j] = max(f[i][j], f[i + k][j - 1]);
if(f[i][j] != -INF) f[i][j] += w[i];
}
cout << f[0][t];
}
标签:std,小明,第二点,const,int,max,namespace,五个,main 来源: https://www.cnblogs.com/tomori/p/13760895.html