7.26 E
来源:互联网 发布:思迅天店软件怎么样 编辑:程序博客网 时间:2024/05/22 11:52
E - Super Jumping! Jumping! Jumping!
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.
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.
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.
3 1 3 24 1 2 3 44 3 3 2 10
4103
#include<stdio.h>#include<string.h>int a[5000],c[5000];int max(int x,int y){if(x<y)x=y;return x;}int main(){int i,j,k,t,n;while(scanf("%d",&n),n!=0){for(i=1;i<=n;i++){scanf("%d",&a[i]);}memset(c,0,sizeof(c));c[1]=a[1];for(i=2;i<=n;i++){for(j=1;j<=i;j++){if(a[i]>a[j]){c[i]=max(c[i],c[j]+a[i]);}}c[i]=max(c[i],a[i]);}t=0;for(i=1;i<=n;i++){if(c[i]>t)t=c[i];}printf("%d\n",t);}return 0;}
阅读全文
0 0
- 7.26 E
- e
- E
- E
- e
- e
- e
- e
- e
- E
- e
- E
- e
- e
- E
- e
- e
- e
- centos 卸载python和yum之后的解决办法
- SpringMVC接收复杂集合参数
- UVA11572UniqueSnowflakes
- 数据库----(linux下安装mysql-5.7.19 创建数据库并且导入数据库文件 教程)
- Battery Historian2.0 windows下安装
- 7.26 E
- 一个帖子学会Android开发四大组件
- Apache Poi导出Excel多Sheet页详解!
- IE 、Edge、360兼容模式 浏览器背景抖动处理
- 根据子网掩码判断网段有效的IP地址
- pom配置之:<distributionManagement>snapshot快照库和release发布库
- Redis重要概念Master-Slave、Sentinel、Partition、Cluster
- 暑期集训之阶乘之和
- 【Codeforces2015ICL,Finals,Div. 1#J】Ceizenpok's formula(扩展Lucas定理+中国剩余定理)