HDU 1087 Super Jumping! Jumping! Jumping! (动态规划、最大上升子序列和)
Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 59516 Accepted Submission(s): 27708
Problem Description
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
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
Sample Input
Sample Output
题目大意与分析
每次给你一个数字n紧接着是n个数,代表棋子大小,每次要从第一个棋子开始,跳到最后一个,每次都要跳到比前一个大的棋子上,问跳过的棋子和最大为多少
题面写了这么多,其实就是求最大的上升子序列的和,把最长上升子序列的模板改一下就好了。
代码
#include<bits/stdc++.h> using namespace std; int a[],dp[],i,n,len,anss,j; int main()
{
while(scanf("%d",&n),n!=)
{
len=;
anss=;
for(i=;i<n;i++)
{
cin>>a[i];
dp[i]=a[i];
}
for(i=;i<n;i++)
{
for(j=;j<i;j++)
{
if(a[i]>a[j])
{
dp[i]=max(dp[i],dp[j]+a[i]);
}
}
}
for(i=;i<n;i++)
{
anss=max(anss,dp[i]);
}
cout<<anss<<endl; }
}
HDU 1087 Super Jumping! Jumping! Jumping! (动态规划、最大上升子序列和)的更多相关文章
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 200 ...
- 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! 最长递增子序列(求可能的递增序列的和的最大值) *
Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
- 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! Problem Description Nowadays, a kind of chess game called “Super Ju ...
- HDU 1087 Super Jumping....(动态规划之最大递增子序列和)
Super Jumping! Jumping! Jumping! Problem Description Nowadays, a kind of chess game called “Super Ju ...
- hdu 1087 Super Jumping! Jumping! Jumping!(动态规划)
题意: 求解最大递增子序列. 例如:3 1 3 2 输入 3 个数 1 3 2 则递增子序列有 {1} {3} {2} {1 3} {1 2} ,故输出子序列的最大和 4 解题思路: x[n](n个 ...
- HDU 1087 Super Jumping! Jumping! Jumping! 最大递增子序列
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
随机推荐
- List集合的方法总结
1. 添加方法 boolean add(E e): 向集合的末尾添加指定的元素 boolean addAll(Collection<? extends E> c): 向集合的末尾添加一个指 ...
- sh_05_列表遍历
sh_05_列表遍历 name_list = ["张三", "李四", "王五", "王小二"] # 使用迭代遍历列表 ...
- jQuery_插入操作
jQuery的插入方法有很多,有内部插入,也有外部插入,每个插入方式里面还有很多种,本文一一介绍,注释在代码里,直接上代码: 代码: <!DOCTYPE html> <html> ...
- java 调用腾讯云短信api
依赖: <!--腾讯短信依赖--> <dependency> <groupId>com.github.qcloudsms</groupId> <a ...
- C++入门经典-例2.8-输出整数,控制打印格式
1:代码如下: // 2.8.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #incl ...
- SpringBoot&Dubbo&Zookeeper远程调用项目搭建
序言 Dubbo一款分布式服务框架,作为阿里巴巴SOA服务化治理方案的核心框架,通过高性能和透明化的RPC实现服务的远程调用,对服务的负载均衡以及项目的耦合性提供很强的解决方式;具体Dubbo的介绍和 ...
- 使用DBLink方式同步远程数据库中含Blob、Clob字段表的问题解决
在数据库同步中我们经常会用到DBLink方式.DBLink可以将物理上存放于网络的多个数据库在逻辑上当成一个单一的大数据库.开发人员无需关心数据库的网络分布,就能很方便的实现从不同数据库之间读取数据. ...
- Oracle数据表之间的数据同步
保证两个数据表结构相同,如不相同只能同步相同字段; 只是思路,具体请根据需求修改. declare cursor csrn_mon is select * from table2; row_mon c ...
- orcal 根据打分时间计算打分情况
create or replace function F_GET_TEST(in_ny in date,in_project_id in number ) return number is sRetu ...
- Leetcode: 二分搜索法
package com.LeetCode; /** * 算法:二分搜索法查找一个值,并返回索引值 * https://leetcode.com/problems/search-insert-posit ...