HDU1087
来源:互联网 发布:mac使用的p2p软件 编辑:程序博客网 时间:2024/05/22 03:31
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.
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 24 1 2 3 44 3 3 2 10
4103
最大上升子序列和:
dp[i]:以f[i]结尾的最大上升子序列和
#include<iostream>#include<cstdio>using namespace std;int main(){long long t,i, j ,f[1050] = {0},dp[1050] = {0}, max, temp;while(scanf("%lld",&t) != EOF && t != 0){for(i = 1; i <= t; ++i){scanf("%lld", &f[i]);}max = 0;dp[1] = f[1];for(i = 2; i <= t; ++i){temp = 0;for(j = 1; j < i; ++j){if(f[i]> f[j] && temp < dp[j])temp = dp[j];}dp[i] = temp+ f[i];if(max < dp[i]) max = dp[i];}printf("%lld\n",max);}}
阅读全文
0 0
- hdu1087
- hdu1087
- HDU1087
- HDU1087
- hdu1087
- hdu1087
- hdu1087
- hdu1087
- hdu1087
- HDU1087
- hdu1087
- hdu1087
- hdu1087
- hdu1087
- hdu1087
- HDU1087
- HDU1087
- HDU1087(DP)
- 内存分配成功,但并未初始化
- Python3之 字典(dict)
- 关于如何在android系统平台中使用AAR包的问题
- Android 布局
- opencv播放视频
- HDU1087
- Android控件中的一些笔记
- netstat详解
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- C/C++ | 22-10 不用库函数,用C语言实现将一整型数字转化为字符串
- 【贪心】Moving Tables POJ 1083
- 扩展欧几里得定理及其应用
- 【ECCV2016】Detecting Text in Natural Image with Connectionist Text Proposal Network
- MySQL