DP专题训练之HDU 1087 Super Jumping!
Description
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
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
Sample Input
Sample Output
求最大递增序列和~(不要求连续。。)
看样例我以为是求最大连续递增序列和的说~~
//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 ;
}
最新文章
- 【Leafletjs】7.结合echart图表展示信息
- DOM遍历方法
- Python 共享和上传函数模块到PyPI
- .htaccess的应用
- 由浅入深探究mysql索引结构原理、性能分析与优化
- Docker基本命令
- Spring factorybean
- 【JAVAWEB学习笔记】06_jQuery基础
- html中p标签行间距的问题
- JS获得一个对象的所有属性和方法
- lua的String
- 给react-native添加图标和启动屏
- 如何使用JMeter开源性能测试工具来构建Web性能测试体系
- 使用@Autowird注入报空指针异常
- spring整合mybatis框架
- 细说tomcat之应用监控
- [Codeforces896C] Willem, Chtholly and Seniorious (ODT-珂朵莉树)
- UUID自动生成
- 对Java中使用两个大括号进行初始化的理解
- 【前端学习笔记】JavaScript 小案例合集
热门文章
- RelativeLayout中实现控件平分屏幕
- 级联两个bootstrap-table。一张表显示相关的数据,通过点击这张表的某一行,传过去对应的ID,刷新另外一张表。
- utils.js
- 第四篇:白话tornado源码之褪去模板外衣的前戏
- 真机远程调试 ( IOS Android 以及微信,weex)
- mysql 命令行操作1
- Redis: OOM command not allowed when used memory >; ‘maxmemory’
- 利用Servlet导出Excel
- WEB启动时就加载servlet的dopost方法
- docker-compose编写(英文)