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

求最大递增序列和~(不要求连续。。)

看样例我以为是求最大连续递增序列和的说~~

//Asimple
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <limits.h>
#include <time.h>
#define INF 0xfffffff
#define mod 1000000
#define swap(a,b,t) t = a, a = b, b = t
#define CLS(a, v) memset(a, v, sizeof(a))
#define debug(a) cout << #a << " = " << a <<endl
#define abs(x) x<0?-x:x
#define srd(a) scanf("%d", &a)
#define src(a) scanf("%c", &a)
#define srs(a) scanf("%s", a)
#define srdd(a,b) scanf("%d %d",&a, &b)
#define srddd(a,b,c) scanf("%d %d %d",&a, &b, &c)
#define prd(a) printf("%d\n", a)
#define prdd(a,b) printf("%d %d\n",a, b)
#define prs(a) printf("%s\n", a)
#define prc(a) printf("%c", a)
using namespace std;
typedef long long ll;
const int maxn = ;
int n, m, num, T, k, len, ans, sum;
int dp[maxn], a[maxn]; //不一定连续~~~
void input() {
while( ~srd(n) && n ) {
for(int i=; i<n; i++) {
srd(a[i]);
}
CLS(dp, );
dp[] = a[];
for(int i=; i<n; i++) {
for(int j=; j<i; j++) {
if( a[i] > a[j])
dp[i] = max(dp[i], dp[j]+a[i]);
}
dp[i] = max(dp[i], a[i]);
}
ans = ;
for(int i=; i<n; i++) {
ans = max(ans, dp[i]);
}
prd(ans);
}
} int main(){
input();
return ;
}

最新文章

  1. 【Leafletjs】7.结合echart图表展示信息
  2. DOM遍历方法
  3. Python 共享和上传函数模块到PyPI
  4. .htaccess的应用
  5. 由浅入深探究mysql索引结构原理、性能分析与优化
  6. Docker基本命令
  7. Spring factorybean
  8. 【JAVAWEB学习笔记】06_jQuery基础
  9. html中p标签行间距的问题
  10. JS获得一个对象的所有属性和方法
  11. lua的String
  12. 给react-native添加图标和启动屏
  13. 如何使用JMeter开源性能测试工具来构建Web性能测试体系
  14. 使用@Autowird注入报空指针异常
  15. spring整合mybatis框架
  16. 细说tomcat之应用监控
  17. [Codeforces896C] Willem, Chtholly and Seniorious (ODT-珂朵莉树)
  18. UUID自动生成
  19. 对Java中使用两个大括号进行初始化的理解
  20. 【前端学习笔记】JavaScript 小案例合集

热门文章

  1. RelativeLayout中实现控件平分屏幕
  2. 级联两个bootstrap-table。一张表显示相关的数据,通过点击这张表的某一行,传过去对应的ID,刷新另外一张表。
  3. utils.js
  4. 第四篇:白话tornado源码之褪去模板外衣的前戏
  5. 真机远程调试 ( IOS Android 以及微信,weex)
  6. mysql 命令行操作1
  7. Redis: OOM command not allowed when used memory &gt; ‘maxmemory’
  8. 利用Servlet导出Excel
  9. WEB启动时就加载servlet的dopost方法
  10. docker-compose编写(英文)