| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 616 人关注过本帖
标题:杭电1087,为什么我错了
取消只看楼主 加入收藏
conquerorbzm
Rank: 2
等 级:论坛游民
帖 子:35
专家分:33
注 册:2010-7-23
结帖率:77.78%
收藏
已结贴  问题点数:20 回复次数:2 
杭电1087,为什么我错了
#include<stdio.h>
int main()
{
    int i,max,sum,j,m,d=0;
    int n;
    int a[1002];
    while(scanf("%d",&n)!=EOF&&n!=0)
    {    sum=0;max=0;m=0;d=0;
        for(i=0;i<n;i++)
            scanf("%d",&a[i]);
      
        for(i=0;i<n;i++)
        {    sum=a[i];
        for(j=i+1;j<n;j++)
        {   
            if(a[i]>=a[j])
                continue;
            else a[i]=a[j];
            sum+=a[j];
        }
            if(sum>max)
                max=sum;
        
        }
            printf("%d\n",max);
    }
    return 0;
}   
2010-08-13 11:12
conquerorbzm
Rank: 2
等 级:论坛游民
帖 子:35
专家分:33
注 册:2010-7-23
收藏
得分:0 
这时一道简单的dp,我测试的数据都对了,但是系统显示错了。
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.





The game can be played by two or more than two players. It consists of a chessboard(棋盘)and some chessmen(棋子), and all chessmen are marked by a positive integer or “start” or “end”. The player starts from start-point and must jumps into end-point finally. In the course of jumping, the player will visit the chessmen in the path, but everyone must jumps from one chessman to another absolutely bigger (you can assume start-point is a minimum and end-point is a maximum.). And all players cannot go backwards. One jumping can go from a chessman to next, also can go across many chessmen, and even you can straightly get to end-point from start-point. Of course you get zero point in this situation. A player is a winner if and only if he can get a bigger score according to his jumping solution. Note that your score comes from the sum of value on the chessmen in you jumping path.
Your task is to output the maximum value according to the given chessmen list.

 

Input
Input contains multiple test cases. Each test case is described in a line as follow:
N value_1 value_2 …value_N
It is guarantied that N is not more than 1000 and all value_i are in the range of 32-int.
A test case starting with 0 terminates the input and this test case is not to be processed.

 

Output
For each case, print the maximum according to rules, and one line one case.

 

Sample Input
3 1 3 2
4 1 2 3 4
4 3 3 2 1
0
 

Sample Output
4
10
3
2010-08-13 11:43
conquerorbzm
Rank: 2
等 级:论坛游民
帖 子:35
专家分:33
注 册:2010-7-23
收藏
得分:0 
确实是算法错了,看来不能这样做啊!谢谢几位啊
2010-08-13 14:11
快速回复:杭电1087,为什么我错了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019459 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved