hdoj--1087--Super Jumping! Jumping! Jumping!(贪心)
Super Jumping! Jumping! Jumping!

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 2
4 1 2 3 4
4 3 3 2 1
0
4
10
3
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int num[100100],dp[100100];
int main()
{
int n;
while(scanf("%d",&n),n)
{
memset(dp,0,sizeof(dp));
memset(num,0,sizeof(num));
for(int i=0;i<n;i++)
scanf("%d",&num[i]);
int maxx=-0x3f3f3f;
for(int i=0;i<n;i++)
{
dp[i]=num[i];
for(int j=0;j<i;j++)
{
if(num[j]<num[i])
//每次去比j大的数,因为从0开始,从小到大,保证是上升序列
//因为这里对长度没有要求,和最大不一定就是最长的,所以dp不用存长度
dp[i]=max(dp[i],dp[j]+num[i]);
}
maxx=max(maxx,dp[i]);
}
printf("%d\n",maxx);
}
return 0;
}
hdoj--1087--Super Jumping! Jumping! Jumping!(贪心)的更多相关文章
- Hdoj 1087.Super Jumping! Jumping! Jumping!
Problem Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!&quo ...
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- HDU 1087 Super Jumping! Jumping! Jumping!(求LSI序列元素的和,改一下LIS转移方程)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 20 ...
- hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 200 ...
- HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)
Problem Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!&quo ...
- hdu 1087 Super Jumping! Jumping! Jumping!(dp 最长上升子序列和)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 ------------------------------------------------ ...
- HDU 1087 Super Jumping! Jumping! Jumping! 最长递增子序列(求可能的递增序列的和的最大值) *
Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
- DP专题训练之HDU 1087 Super Jumping!
Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is ve ...
- hdu 1087 Super Jumping! Jumping! Jumping! 简单的dp
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- HDU 1087 Super Jumping! Jumping! Jumping! 最大递增子序列
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
随机推荐
- 什么是递归?用十进制转二进制的Python函数示例说明
先上用Python写的十进制转二进制的函数代码: def Dec2Bin(dec): result = '' if dec: result = Dec2Bin(dec//2) return resul ...
- VM-安装MAC系统
搜了下论坛没有这个教程,继续搬运一波,这次教的是用VM15安装Mac OS10.14懒人版VMware安装Windows和Linux比较类似,相对于今天要安装的MAC OS来说过程也比较简单.官方原版 ...
- BZOJ 1951 Lucas定理+CRT
思路: 枚举约数 套个裸的Lucas+CRT就完了... //By SiriusRen #include <cmath> #include <cstdio> using nam ...
- CentOS6.5下编译R源码并安装Spark R
不多说,直接上干货! 为了使用SparkR,决定要在Spark所在的Linux上装上R,结果血泪篇了.主要原因是公司内部的虚机,无法连外网,所以网上很多的直接rpm或者yum的方法都没用,需要自己编译 ...
- 解决生成主键 id重复的解决办法
作者:董春秋链接:https://www.zhihu.com/question/30674667/answer/49082988来源:知乎著作权归作者所有,转载请联系作者获得授权. 全局id生成器.我 ...
- jbox如果弹不出,放在body里
body> <form id="form1" runat="server"> <script type="text/javas ...
- LUA 创建文件和文件夹
创建文件: os.execute('mkdir e:\\aa') 创建文件夹: os.execute("cd.>e:\\wang.ini")
- wordcloud + jieba 生成词云
利用jieba库和wordcloud生成中文词云. jieba库:中文分词第三方库 分词原理: 利用中文词库,确定汉字之间的关联概率,关联概率大的生成词组 三种分词模式: 1.精确模式:把文本精确的切 ...
- 前端-JQ思维导图
看不清的朋友右键保存或者新窗口打开哦!喜欢我可以关注我,还有更多前端思维导图笔记
- (转载)RxJava 与 Retrofit 结合的最佳实践
RxJava 与 Retrofit 结合的最佳实践 作者:tough1985 感谢 DaoCloud 为作者提供的 500 RMB 写作赞助: 成为赞助方 /开始写作 前言 RxJava和Retrof ...