hdu 1087 Super Jumping! Jumping! Jumping!(最大递增字段和)
来源:互联网 发布:剑网3刘亦菲捏脸数据 编辑:程序博客网 时间:2024/05/22 17:44
Problem Description
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
题目大意:
简单来说,就是求最大递增子段和(不一定要连续)
解题思路:
dp可怼
#include<bits/stdc++.h>using namespace std;#define INF 0x3f3f3f3fint d[10005],s[10005];int main(){ int n,ans; while(cin>>n&&n) { for(int i=1;i<=n;i++) cin>>s[i]; memset(d,0,sizeof(d)); for(int i=1;i<=n;i++) { ans=-INF; for(int j=0;j<i;j++) if(s[i]>s[j]) ans=max(ans,d[j]); //第i个数字之前的最大递增字段和 d[i]=ans+s[i]; } ans=-INF; for(int i=0;i<=n;i++) ans=max(ans,d[i]); cout<<ans<<endl; } return 0;}
- hdu 1087 Super Jumping! Jumping! Jumping!(最大递增字段和)
- hdu 1087 Super Jumping! Jumping! Jumping! (最大递增子序列和)
- HDU 1087 Super Jumping! Jumping! Jumping!(求绝对递增子序列的最大和)
- hdu 1087 Super Jumping! Jumping! Jumping!(最大递增子段和)
- HDU 1087 Super Jumping! Jumping! Jumping!(最大递增子串和)
- hdu-1087 Super Jumping! Jumping! Jumping! [最大递增子段和]
- hdu 1087 Super Jumping! Jumping! Jumping! (最大递增子段和)
- Super Jumping! Jumping! Jumping!(HDU-1087)
- hdoj 1087 Super Jumping! Jumping! Jumping!(最大递增子段和)
- hdu 1087 Super Jumping! Jumping! Jumping!(dp+最长递增序列)
- HDU 1087 Super Jumping! Jumping! Jumping! (最大子段和)
- hdu 1087 Super Jumping! Jumping! Jumping!(dp:上升子序列最大和)
- HDU-1087 Super Jumping! Jumping! Jumping!(上升子序列最大和)
- 【HDU 1087】Super Jumping! Jumping! Jumping!(最大上升子序列和,动态规划)
- HDU 1087 Super Jumping! Jumping! Jumping![动态规划——最大递增子序列]
- HDU 1080-Super Jumping! Jumping! Jumping!(LIS最长上升子序列-最大递增子段和)
- hdoj 1087 Super Jumping! Jumping! Jumping! 【dp&&最大递增子段和】
- hdu1087 Super Jumping! Jumping! Jumping! (求最大递增子序列和)
- 语音信号的同态处理、倒谱分析和Mel频率倒谱系数
- HDU-1014 Uniform Generate
- 5-7 六度空间 (30分)
- Bayesian Network Fundamentals
- milk
- hdu 1087 Super Jumping! Jumping! Jumping!(最大递增字段和)
- 1352 - Colored Cubes ---make
- CSS3 动画属性 animation 的基本用法
- android Service和Activity的通信
- java并发每日一练
- 第一篇博客
- ubuntu16.04编译android6.0 make: *** [out/host/linux-x86/obj32/lib/libartd.so] Error 1错误
- erb模板预定义方法
- hdu 1506 Largest Rectangle in a Histogram(最大子矩阵)