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 ...
随机推荐
- C#使用ICSharpCode.SharpZipLib.dll进行文件的压缩与解压
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...
- 百度地图api的简单应用
百度地图api 获取经纬度(通过浏览器的) //获取经纬度 window.navigator.geolocation.getCurrentPosition(function(position) { a ...
- spring IOC(DI)和AOP
软件152谭智馗 IOC(Inversion of Control,控制倒转)Ioc意味着将你设计好的对象交给容器控制,而不是传统的在你的对象内部直接控制. DI—Dependency Injecti ...
- open source project for recommendation system
原文链接:http://blog.csdn.net/cserchen/article/details/14231153 目前互联网上所能找到的知名开源推荐系统(open source project ...
- 易观OLAP算法大赛结果揭晓,开源组黑马放大招!
100+天激烈赛程,40+国内顶级技术豪门对决,历经研发内部测试.正式环境测试和易观数据正式环境跑benchmark三大阶段.10月28日,易观OLAP算法大赛优胜名单出炉! 40+技术门派比武 易观 ...
- 基于libVLC的视频播放器
本文来自于:http://blog.csdn.net/leixiaohua1020/article/details/42363079 最简单的基于libVLC的例子:最简单的基于libVLC的视频播放 ...
- Auto Layout压缩阻力及内容吸附讲解
Auto Layout压缩阻力及内容吸附讲解 本文为投稿文章,作者:梁炜V 在Auto Layout的使用中,有两个很重要的布局概念:Content Compression Resistance 和 ...
- mach-o可执行文件结果
使用工程:machoview
- day06-08面向对象的三大特性
一.继承 1.1什么是继承?继承是一种创建新类的方式,在python中,新建的类可以继承一个或多个父类,父类又可称为基类或超类,新建的类称为派生类或子类python中类的继承分为:单继承和多继承 cl ...
- VS Code中编写html(5) 标签的布局设置
1 <!--首先在div中添加四个span标签--> <div> <!--span*4+tab--> <!--span{span$}*4--> < ...