HDU 1087 最大上升子序列的和
Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 32134 Accepted Submission(s): 14467
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.
0
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n;
int a[];
int ans[];
int exm;
int main()
{
while(scanf("%d",&n)!=EOF)
{
if(n==)
break;
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
ans[i]=a[i];
}
int maxlen=-;
for(int i=;i<=n;i++)
{
int maxn=;
for(int j=;j<i;j++)
{
if(a[j]<a[i]&&maxn<ans[j])
{
maxn=ans[j];
}
}
ans[i]=maxn+a[i];
if(ans[i]>maxlen)
{
maxlen=ans[i];
exm=i;
}
}
cout<<maxlen<<endl;
}
return ;
}
最新文章
- [LeetCode] Single Number 单独的数字
- 洛谷P2409 Y的积木
- 使用百度网盘+Git,把版本控制托管到云端
- JSONP的小示例
- Latex及Beamer
- Struts+Spring+Hibernate进阶开端(一)
- 简单解析nestJS目录
- Django中views笔记
- 破解网页右键被禁止js
- [CSL 的字符串][栈,模拟]
- flask框架的教程--虚拟环境的安装[一]
- C语言实现二叉树的建立、遍历以及表达式的计算
- bootstrap 列表--水平定义列表
- tar 打包当前目录下文件但不包括该录
- Origin绘制双Y轴图的方法
- ORACLE递归查询(适用于ID,PARENTID结构数据表)
- codevs 1795 金字塔 2
- MikroTik RouterOS 6.x版本开始支持使用img镜像安装(U盘安装的终极解决方法)
- 在虚拟机中安装Ubuntu详细过程
- 眼前一亮!十八款新潮而又独特的网站Header设计
热门文章
- LVS+Keepalived-DR模式负载均衡高可用集群
- 微信公众号支付java版本
- 【Mysql】给mysql配置远程登录
- ubuntu配置命令
- 1016-01-首页16-计算配图的frame----MJExtention的使用
- 001---web应用程序
- [USACO12JAN]视频游戏的连击Video Game Combos(AC自动机+DP)
- Spring.net Ioc 依赖注入
- Service Intent must be explicit
- django中间件CsrfViewMiddleware源码分析,探究csrf实现