标签:style blog color io for div amp log
#include <cstdio> #include <algorithm> using namespace std; #define maxn 2100 int dp[maxn][maxn]; int val[maxn]; int n; int main() { while(scanf("%d",&n)!=EOF) { int i,j; for(i=1;i<=n;i++) { scanf("%d",&val[i]); dp[i][i]=n*val[i]; } for(i=n-1;i>=1;i--) for(j=i;j<=n;j++) { int fac=n-(j-i); dp[i][j]=max(dp[i+1][j]+fac*val[i],dp[i][j-1]+fac*val[j]); } printf("%d\n",dp[1][n]); } return 0; }
poj 3186 Treats for the Cows dp,布布扣,bubuko.com
poj 3186 Treats for the Cows dp
标签:style blog color io for div amp log
原文地址:http://www.cnblogs.com/vermouth/p/3917449.html