标签:
Description
Input
Output
Sample Input
Sample Output
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=1100;
int dp[maxn];
int a[maxn];
int main(){
int n;
while(scanf("%d",&n)!=EOF){
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
memset(dp,0,sizeof(dp));
for(int i=1;i<=n;i++){
for(int j=i;j>=1;j--){
dp[i]=max(dp[i],dp[j-1]+(a[i]-a[j])*(a[i]-a[j]));
}
}
printf("%d\n",dp[n]);
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/chengsheng/p/4335798.html