LIS

 

D - LIS
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

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<stdio.h>
#include<string.h>
int  main(){
	int n,dp[10010],a[10010];
	while(scanf("%d",&n),n!=0){
		int m=0;
		for(int i=0;i<n;i++){
				scanf("%d",&a[i]);
				dp[i]=a[i];
		}
			for(int i=0;i<n;i++){
				int max=0;
				for(int j=0;j<i;j++){
					if(a[j]<a[i]&&dp[j]>max){
						max=dp[j];
					}
					
				}
				dp[i]+=max;
			}
			int nax = 0;
			for(int i=0;i<n;i++){
				if(dp[i]>nax)nax=dp[i];
			}
			printf("%d\n",nax);
		
	}
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Lis Delphi是一个创新科技公司,专注于开发和提供高质量的软件解决方案。该公司成立于20xx年,总部位于中国上海。Lis Delphi的主要产品和服务包括开发工具、编程语言、数据库管理系统以及各种定制化的软件解决方案。 Lis Delphi的开发工具主要是针对软件开发人员的,旨在提供一套强大的开发工具,帮助开发人员更高效地开发出功能强大、稳定可靠的软件。该开发工具具有友好的用户界面和丰富的功能模块,可以满足开发人员的各种需求。 与此同时,Lis Delphi还提供一种名为Delphi的编程语言。Delphi是一种基于对象的编程语言,结合了传统的编程语言和面向对象思想的特点。它易于学习和使用,并且具有高度可读性和可维护性。许多开发人员选择使用Delphi语言进行软件开发,因为它能够提供高效的开发环境和强大的功能。 此外,Lis Delphi还开发了一套数据库管理系统,用于帮助用户管理和存储大量的数据。这个数据库管理系统具有高速、可靠和安全等特点,可以有效地管理企业的数据,提高数据处理效率。 最后,Lis Delphi也提供各种定制化的软件解决方案。无论是企业内部的管理系统,还是对外提供的在线服务,Lis Delphi都能根据客户需求开发出最合适的解决方案,帮助客户实现数字化转型,提高业务效率。 总的来说,Lis Delphi是一家专注于软件开发和提供解决方案的科技公司,致力于提供高质量的开发工具、编程语言、数据库管理系统以及定制化的软件解决方案,满足客户的各种需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值