| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
20行代码~#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=2000+10;
int d[MAXN][MAXN],a[MAXN];
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=1;i<=n;i++)
d[i][i]=n*a[i];
for(int i=n-1;i>0;i--)
for(int j=i+1;j<=n;j++)
d[i][j]=max(d[i+1][j]+(n-j+i)*a[i],d[i][j-1]+(n-j+i)*a[j]);
printf("%d\n",d[1][n]);
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator