D - LIS
来源:互联网 发布:python程序调试 编辑:程序博客网 时间:2024/04/30 19:44
D - LIS
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescription
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.
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.
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 24 1 2 3 44 3 3 2 10
Sample Output
4103
解答:
#include <stdio.h>#include <string.h>#include <iostream>//题目的要求是选择最长并且最大的序列和using namespace std;int main (){ int a,i,j; int b[10001],c[10001]; int max;while (scanf ("%d",&a)!=EOF){ if(a==0) break; for(i=0;i<a;i++) { scanf ("%d",&b[i]); } max=b[0]; for(i=0;i<a;i++) { c[i]=b[i]; for(j=0;j<=i;j++) { if(b[i]>b[j]&&c[i]<c[j]+b[i])//选出前面比这个数小的所有数,比较他们的总和的值。 c[i]=c[j]+b[i]; } if (c[i]>max) max=c[i]; } printf("%d\n",max);}}
0 0
- D - LIS
- CF - 463D LIS + 思维
- Codeforces #323 D. Once Again... (LIS)
- codeforces 583 D. Once Again... (LIS + 贪心)
- Codeforces Round #323 (Div. 2)D lis
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- hdu 2544 最短路
- hdu 4565 So Easy!
- 青海哪里找富婆包养
- jQuery数字滚动展示效果
- 这么热的天,要做什么才能降温呢
- D - LIS
- 常用Eclipse快捷键
- android抓包工具fiddler抓包使用方法 跟踪监控android数据包
- java.lang.IncompatibleClassChangeError: Implementing class异常解决方法
- ECCV 2014 accepted papers
- UCOSII学习笔记:任务调度(摘自原子教程)
- mainCRTStartup
- OpenGL: 透明 不透明 混合【3D游戏引擎设计】
- oracle11g安装