G - Super Jumping! Jumping! Jumping!

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

嗯这题我是百度的 不知道要怎么说我觉得我的思路是对的 就是和百度上有一点点的不一样 我是逆向过来的   但是wa了

如果你恰好看到恰好知道嘿嘿麻烦告诉我~~~~~~~~~谢谢

代码如下

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int dp[1005];
int num[1005];
int main()
{int n;while(scanf("%d",&n)&&n>0){for(int i=1;i<=n;i++){scanf("%d",&num[i]);dp[i]=num[i];}memset(dp,0,sizeof(dp));dp[1]=num[1];int maxx=dp[1],i,j;for(i=1;i<=n;i++){for( j=i+1;j<=n;j++){if(num[j]>num[i])dp[j]=max(dp[j],dp[i]+num[j]);if(dp[j]>maxx)maxx=dp[j];    }}printf("%d\n",maxx);}return 0;
}

正确的代码如下:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int dp[1005];
int num[1005];
int main()
{int n;while(scanf("%d",&n)&&n>0){for(int i=1;i<=n;i++){scanf("%d",&num[i]);dp[i]=num[i];}memset(dp,0,sizeof(dp));dp[1]=num[1];int maxx=dp[1],i,j;for(i=2;i<=n;i++){dp[i]=num[i];for(j=1;j<i;j++){if(num[j]<num[i])dp[i]=max(dp[i],dp[j]+num[i]);  }  if(dp[i]>maxx)maxx=dp[i];  }printf("%d\n",maxx);}return 0;
}

G - Super Jumping! Jumping! Jumping!(动态规划)相关推荐

  1. python类的继承super方法_Python类的继承super相关原理解析

    看了网上许多关于super.mro.C3的介绍感觉没有一份很容易初学者理解的文档,直接看C3算法的话,比较难理解,也没必要,如果掌握一套规律的话,会轻松许多.我将网上这些博主的文章进行一个梳理总结,最 ...

  2. super()继承关系总结

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言 一.继承 二.就近并行.同父滞后 1.就近并行 2.同父滞后 前言 复杂继承关系时,顺口溜:多父类继承时,就近并行,同 ...

  3. Python类中super()和__init__()的关系

    区分单继承和多重继承 https://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/00138 ...

  4. python中super().__init__()

    文章目录 super().__ init__ ()有什么用? 1.分别理解super()和 __ init __() 1.1.super() 1.2.__ init __() 1.3.super(). ...

  5. 抽象类试验。定义一组具有继承关系的类。Shape(形状)类是一个抽象类,包含4个数据成员(坐标x,y,颜色c,图形对象g(Graphics类对象))

    package Test5_1_zxj; import javax.swing.*; import java.awt.*; public abstract class Shape {// 抽象类试验. ...

  6. hdu 1087 Super Jumping! Jumping! Jumping! 动态规划

    Super Jumping! Jumping! Jumping! Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K ...

  7. 动态规划训练17 [Super Jumping! Jumping! Jumping! HDU - 1087 ]

    Super Jumping! Jumping! Jumping! HDU - 1087 过于简单懒得说了 #include <cstdio> #include <algorithm& ...

  8. HDU 1087 [Super Jumping! Jumping! Jumping!]动态规划

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 题目大意:有N个格子,每个格子有数值.从原点开始跳,可以跳到任何一个位置:在某一个位置,只能跳到 ...

  9. 基于3D关节点的人体动作识别综述(转)

    原文:2016,Pattern Recognition: 3D skeleton-based human action classification: A survey 摘要 近年来,基于深度序列的人 ...

  10. 当前进度,已学算法,未做题目

    当前学习 CSP-S备战中 已学算法 从初一开始算起,按照时间顺序排序 算法简称 算法全称 备注 无 高精度 比较基础的算法 d e p t h f i r s t s e a r c h ( D F ...

最新文章

  1. python中列表常用方法_Python中列表的常用方法
  2. 关于webpack的使用
  3. Luogu3694 邦邦的大合唱站队 (状压DP)
  4. 计算机视觉开源库OpenCV之查找轮廓函数cv2.findContours()介绍
  5. 美团O2O排序解决方案——线上篇
  6. 0319互联网新闻 | 网易云课堂和中国大学MOOC并入网易有道;快手上线快手概念版...
  7. ASP防止SQL注入-代码片段
  8. E-Prime 软件中常用的 inline 语句
  9. shell 脚本-while用法
  10. 建行u盾弹不出来_建设银行网银盾检测不到怎么解决
  11. SQL函数入门--统计函数+分组函数
  12. MATLAB工具箱——Classification Learner使用
  13. LeetCode 13 罗马符号转化为数字(难度: Easy)
  14. 鼠标右键点击文件夹、bat文件、txt文档,指针出现假死转圈的解决方法(Adobe Acrobat右键邮件选项引起的win10假死)
  15. 由legacy+MBR改为UEFI+GPT引导方式
  16. 支持自动打怪(内挂)的网游,更新日期15.3.2
  17. P1786 帮贡排序c++良心题解
  18. web开发报错:The origin server did not find a current representation for the target…
  19. c语言实现页面调度算法实验报告,c语言实现调度算法程序设计实验报告-先来先服务fcfs.docx...
  20. 苹果怎么测是原装屏_怎么在不拆机的前提判断你的iPhone是不是原装屏?

热门文章

  1. 未捕获异常string was not recognized_给你代码:PHP7中的异常与错误处理
  2. MySQL双主机双Master方案测试
  3. 用Wireshark轻松解密TLS浏览器流量
  4. poj 3074 Sudoku
  5. VPP电源控制(VPP Power)-- 由DC-DC变换集成电路MC34063组成
  6. 【网摘】ActiveX组件及其注册
  7. RocketMq最佳实践
  8. mysql 修改登录用户名和密码
  9. Windows Azure Virtual Machine (33) Azure虚拟机删除重建
  10. 深入浅出分布式系统Raft协议