HDU1087:Super Jumping! Jumping! Jumping!(DP水题)
Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 63733 Accepted Submission(s): 29669
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.
4 1 2 3 4
4 3 3 2 1
0
10
3

#define _CRT_SECURE_NO_DepRECATE
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cctype>
#include <iterator>
#include <vector>
#include <cstring>
#include <cassert>
#include <map>
#include <queue>
#include <set>
#include <stack>
#define ll long long
#define INF 0x3f3f3f3f
#define ld long double
const ld pi = acos(-.0L), eps = 1e-;
int qx[] = { ,,,- }, qy[] = { ,-,, }, qxx[] = { ,- }, qyy[] = { ,- };
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie();
ll n, num[], dp[], maxx;
while (cin >> n && n)
{
memset(dp, , sizeof(dp));
for (int i = ; i < n; i++)
{
cin >> num[i];
}
for (int i = ; i < n; i++)
{
maxx = ;
for (int f = ; f < i; f++)//遍历找出能跳到i的最大的值
{
if (num[i] > num[f])
{
maxx = max(dp[f], maxx);
}
}
dp[i] = maxx + num[i];
}
for (int i = ; i < n; i++)
{
maxx = max(maxx, dp[i]);
}
cout << maxx << endl;
}
return ;
}
HDU1087:Super Jumping! Jumping! Jumping!(DP水题)的更多相关文章
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- [poj2247] Humble Numbers (DP水题)
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...
- Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题
除非特别忙,我接下来会尽可能翻译我做的每道CF题的题面! Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题 题面 胡小兔和司公子都认为对方是垃圾. 为了决出谁才是垃 ...
- 13年山东省赛 The number of steps(概率dp水题)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud The number of steps Time Limit: 1 Sec Me ...
- dp水题 序列问题 (9道)
9道题.A了8道,A题看题解也没弄懂怎么维护m段子序列的,过一段时间再回来看看 dp试水 47:56:23 125:00:00 Overview Problem Status Rank ( ...
- codeforces 637D D. Running with Obstacles(dp,水题,贪心)
题目链接: D. Running with Obstacles time limit per test 2 seconds memory limit per test 256 megabytes in ...
- 【BZOJ】1270: [BeijingWc2008]雷涛的小猫(DP+水题)
http://www.lydsy.com/JudgeOnline/problem.php?id=1270 这完全是一眼题啊,但是n^2的时间挺感人.(n^2一下的级别请大神们赐教,我还没学多少dp优化 ...
- 【DP水题】投票问题(二)
投票问题(一) [试题描述] 欧阳文和欧阳武竞选学联主席,汪梁森负责唱票,共有m+n张,结果欧阳文获胜,已知欧阳文和欧阳武分别获得 m 张票和 n 张票(m>n).现在请你计算在唱票过程中欧阳文 ...
- 学校作业-Usaco DP水题
好吧,因为USACO挂掉了,所以我写的所有代码都不保证正确性[好的,这么简单的题,再不写对,你就可以滚粗了! 第一题是USACO 2.2.2 ★Subset Sums 集合 对于从 1 到 N 的连 ...
随机推荐
- bootstrap table分页跳转到第一页
1.destroy后重新初使化表格,可以将表格初始化封装为一个函数,destory后重新调用该函数进行初始化: 2.使用url刷新表格,$('#table').bootstrapTable('refr ...
- NoVNC API 文档翻译
原文地址:https://github.com/novnc/noVNC/blob/master/docs/API.md 时间:2019-05-21 noVNC API The interfac ...
- 部署nginx后无法访问数据库,查看www-error.log日志报错Class 'mysqli' not found in /usr/local/nginx/html/mysql.php on line 2
检查你的php-mysql包是否安装 [root@localhost nginx]# rpm -qa php-mysql 没有任何输出则没有安装,接下来用yum安装php-mysql yum -y i ...
- 关于Resouces.resx 在WPF中{x:Static}不显示内容只显示字段的问题解决办法
问题现象:<object property="{x:Static prefix:typeName.staticMemberName}" .../> 界面中只显示资源引用 ...
- img标签src="[object Moudle]"问题解决办法
在写组件的时候,按照如下方式来写,加载不出图片: 打开开发者工具,发现img标签对应位置显示如下: 我之前已经下载过 url-loader 解决方法如下: 加入 esModules:false 即可
- 超实用的Flask入门基础教程,新手必备!
Flask入门基础教程 Flask简介 Flask是一个轻量级的可定制框架,使用Python语言编写,较其他同类型框架更为灵活.轻便.安全且容易上手.它可以很好地结合MVC模式进行开发,开发人员分工合 ...
- Linux下安装MySQL的tar.gz包
以root用户登录待安装的服务器. 上传软件包并解压. 以root用户通过sftp/ftp工具上传“mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz”软件包到“/o ...
- beautifulsoup实现文章截取和脚本攻击
引子:现在我们所写的所有高大上,炫酷的网页,在数据库中是如何存储的呢?其实数据库中存储的所有高大上的文章都是存的html,然后我们平时看的写的都是由于编辑器的原因,在编辑器内部做了转换,所以我们可以直 ...
- hdu2642二维树状数组,单点修改+区间查询
题目链接:http://icpc.njust.edu.cn/Problem/Hdu/2642/ 代码如下: #include<bits/stdc++.h> using namespace ...
- 洛谷 P2568 GCD 题解
原题链接 庆祝一下:数论紫题达成成就! 第一道数论紫题.写个题解庆祝一下吧. 简要题意:求 \[\sum_{i=1}^n \sum_{j=1}^n [gcd(i,j)==p] \] 其中 \(p\) ...