hdu_1087_和做的上一个递推一样_简单_不必复习
来源:互联网 发布:域名com cn top net 编辑:程序博客网 时间:2024/05/16 06:22
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.
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
#include<iostream>#include<cstdio>#include<cstring>using namespace std;int main(){ int n; while(cin>>n &&n) { int num[1111],dp[1111]= {0},i,j; for(i=0; i<n; i++) scanf("%d",num+i); for(i=0; i<n; i++) { dp[i]=num[i]; for(j=0; j<i; j++) { if(num[j]<num[i]) dp[i]=max(dp[i],dp[j]+num[i]); } } int ans=0; for(i=0; i<n; i++) ans=max(ans,dp[i]); cout<<ans<<endl; } return 0;}
- hdu_1087_和做的上一个递推一样_简单_不必复习
- 复习_简单命令
- poj_1611_模拟递推_刚做过类似
- 树的重量_洛谷1268_递推
- HDU2045_LELE的PRG难题_递推
- c++基础复习_简单程序
- 黑马程序员_接口和包的复习
- 实验吧简单的sql注入--三题答案一样--_--
- 过河问题_纪中2558_递推
- 数字三角形_递归_递推(动态规划)
- 9种基本算法_递推
- JAVA高精度4_递推求值
- 多线程的概念_供学员复习
- 【数据库复习_查询的逻辑处理】
- Java复习_多线程
- 【数据库复习_索引】
- 【数据库复习_视图】
- 【数据库复习_触发器】
- lintcode -- 最大数
- ubuntu 1604 桌面版中配置mesos测试环境
- 关于mysql优化原理收获不少的文章
- 二维数组中的查找
- Java读取word文件
- hdu_1087_和做的上一个递推一样_简单_不必复习
- 顺序表
- UVa1593 Alignment of Code
- 170819 四步安装Ubuntu 16.04 搜狗拼音输入法
- Android Studio 之 NDK篇
- STL之Map和multimap容器
- 初试docker-compose
- 最大容积--Container With Most Water of leetcode
- 算法题/丑数