lalalala


私信TA

用户名:zhangshuo

访问量:153421

签 名:

像狗一样的学习,像绅士一样地玩耍。

等  级
排  名 6
经  验 30314
参赛次数 10
文章发表 201
年  龄 12
在职情况 学生
学  校 芜湖市第十一中学
专  业

  自我简介:

今日懒惰流下的口水,将会成为明日里伤心的泪水。

解题思路:





注意事项:





参考代码:

#include<stdio.h>  
#include<string.h>  
#define max(a,b) (a>b?a:b)  
int a[2020];  
int dp[2002][2002];  
int n;  
int dfs(int l,int r,int time)  
{  
    if(l>r)  
        return 0;  
    if(dp[l][r])  
        return dp[l][r];  
    int temp=0;  
    temp=max(temp,dfs(l+1,r,time+1)+time*a[l]);  
    temp=max(temp,dfs(l,r-1,time+1)+time*a[r]);  
    return dp[l][r]=temp;  
}  
int main()  
{  
//  int n;  
    while(scanf("%d",&n)!=EOF)  
    {  
        int i,j;  
        for(i=1;i<=n;i++)  
        {  
            scanf("%d",&a[i]);  
        }  
        printf("%d\n",dfs(1,n,1));  
    }  
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

我是不是膨胀了,直接就翻到这一页了。嘿嘿嘿
2018-07-29 09:37:17
  • «
  • 1
  • »