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 |
= =、写的好漂亮?#include<iostream> #include<cstdio> #include<math.h> #include<queue> #include<map> #include<stdlib.h> #include<string> #include<string.h> #include<algorithm> using namespace std; typedef long long LL; #define INF 0x3f3f3f3f #define PI acos(-1.0) const int N=1e3+10; int a[N*2]; int dp[N*2][N*2]; int n; int main() { cin>>n; for(int i=1;i<=n;i++) scanf("%d",&a[i]); memset(dp,0,sizeof(dp)); for(int i=n;i>=1;i--){ for(int j=i;j<=n;j++) dp[i][j]=max(dp[i+1][j]+(n-(j-i))*a[i],dp[i][j-1]+(n-(j-i))*a[j]); } cout<<dp[1][n]<<endl; } /* 5 1 3 1 5 2 */ Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator