- 佳佳的魔杖
- 2013-10-08 22:29:24 @
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
int n,f[1001][1001],maxh,minh,w[1001][1001];
void init()
{
int l[1001][1001];
cin>>n>>minh>>maxh;//scanf("%d%d%d",&n,&minh,&maxh);
for (int i=1;i<=n;i++) cin>>l[i][i];//scanf("%d",&l[i][i]);
for (int i=1;i<=n;i++) cin>>w[i][i];//scanf("%d",&w[i][i]);
for (int i=1;i<=n-1;i++)
for (int j=i+1;j<=n;j++)
{
l[i][j]=l[i][j-1]+l[j][j];
w[i][j]=w[i][j-1]+w[j][j];
}
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
if (l[i][j]<minh||l[i][j]>maxh)
w[i][j]=0;
return;
}
int main()
{
init();
for (int i=1;i<=n;i++)
for (int j=i;j<=n;j++)
f[i][j]=max(f[i-1][j-1]+w[i][j],max(f[i-1][j],f[i][j-1]));
cout<<f[n][n]<<endl;
return 0;
}
2 条评论
-
kevin31209 LV 6 @ 2016-09-17 08:35:38
// input code here
-
2015-10-28 20:21:26@
因为你丑!!
- 1