| 记录编号 | 
        32610 | 
        评测结果 | 
        AAAAAAAAAA | 
    
    
        | 题目名称 | 
        608.删数 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         TBK | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.004 s  | 
    
    
        | 提交时间 | 
        2011-11-07 14:51:35 | 
        内存使用 | 
        0.27 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include <iostream>   
#include <cstdio>   
#include <cstdlib>   
#include <cmath>   
#include <cstring>   
#include <string>   
#include <algorithm>   
#include <iomanip>   
using namespace std;  
int a[101],b,c,d,l,m,n,f1[100]={0},f2[100]={0},t,s;
int ab(int x)
{
	return x>0?x:0-x;
}
int main(void)   
{   
    freopen ("remove.in","r",stdin);   
    freopen ("remove.out","w",stdout);   
	scanf("%d",&b);
	for (c=1;c<=b;c++) cin>>a[c];
	f1[1]=a[1];
	for (c=2;c<=b;c++)
	{
		f1[c]=ab(a[c]-a[1])*c;
		if (f1[c-1]+a[c]>f1[c]) f1[c]=f1[c-1]+a[c];
		for (d=c-2;d>=1;d--)
			if (f1[d]+ab(a[c]-a[d+1])*(c-d)>f1[c]) f1[c]=f1[d]+ab(a[c]-a[d+1])*(c-d);
		
	}
	f2[1]=a[b];
	for (c=2;c<=b;c++)
	{
		f2[c]=(ab(a[b-c+1]-a[b]))*c;
		if (f2[c-1]+a[b-c+1]>f2[c]) f2[c]=f2[c-1]+a[b-c+1];
		for (d=c-2;d>=1;d--)
			if (f2[d]+ab(a[b-d]-a[b-c+1])*(c-d)>f2[c]) 
				f2[c]=f2[d]+ab(a[b-d]-a[b-c+1])*(c-d);
	}
	s=0;
	for (c=0;c<=b;c++)
		if (f1[c]+f2[b-c]>s) s=f1[c]+f2[b-c];
	cout<<s;
    fclose(stdin);   
    fclose(stdout);   
    return 0;   
}