华为OJ(Redraiment的走法)
2015-08-19 10:56
363 查看
描述 | 题目描述 Redraiment是走梅花桩的高手。Redraiment总是起点不限,从前到后,往高的桩子走,但走的步数最多,不知道为什么?你能替Redraiment研究他最多走的步数吗? 样例输入62 5 1 5 4 5 样例输出3 提示Example: 6个点的高度各为 2 5 1 5 4 5 如从第1格开始走,最多为3步, 2 4 5 从第2格开始走,最多只有1步,5 而从第3格开始走最多有3步,1 4 5 从第5格开始走最多有2步,4 5所以这个结果是3。 接口说明方法原型: int GetResult(int num, int[] pInput, List pResult);输入参数: int num:整数,表示数组元素的个数(保证有效)。 int[] pInput: 数组,存放输入的数字。输出参数: List pResult: 保证传入一个空的List,要求把结果放入第一个位置。 返回值: 正确返回1,错误返回0 |
---|---|
知识点 | 排序 |
运行时间限制 | 10M |
内存限制 | 128 |
输入 | 输入多行,先输入数组的个数,再输入相应个数的整数 |
输出 | 输出结果 |
样例输入 | 6 2 5 1 5 4 5 |
样例输出 | 3 |
#include<iostream> using namespace std; int main() { int n,maxstep=0; cin>>n; int *step=new int[n+1]; int *height=new int ; for(int i=0;i<n;i++) { cin>>height[i]; step[i]=1; } step =1; for(int i=1;i<n;i++) for(int j=0;j<i;j++) if(height[i]>height[j]&&step[j]+1>step[i]) { step[i]=step[j]+1; if(step[i]>maxstep) maxstep=step[i]; } cout<<maxstep<<endl; //system("pause"); return 0; }
相关文章推荐
- 【android学习笔记】理解android.intent.action.MAIN 与 android.intent.category.LAUNCHER
- 2015 Multi-University Training Contest 9-1007 Travelling Salesman Problem
- Communications link failure Last packet sent to the server was 0 ms ago.问题解决
- HDU 5402 Travelling Salesman Problem (2015 Multi-University Training Contest 9 2015多校联合)
- Aisen新浪微博客户端项目源码
- tools:context=".MainActivity的作用
- HDU 5405 Sometimes Naive 2015多校联合训练赛#9 LCT 树链剖分
- 马尔可夫链及吉布斯抽样 入门详解(Markov Chain Monte Carlo and Gibbs Sampling)
- 再谈应用环境下的TIME_WAIT和CLOSE_WAIT
- 2015 HUAS Summer Trainning #6~I
- Contain Duplicate III*******
- Contain Duplicate II
- offsetof 和 container_of
- Contain Duplicate
- Fair Division
- Unable to find a team with the given Team ID或者Failed to code sign的问题解决
- linuc之waitpid
- POJ 1285 - Combinations, Once Again 泛化背包!
- 2015 Multi-University Training Contest 9 1007
- Can't find keyplane that supports type 4 for keyboard iPhone-PortraitChoco-NumberPad; using 27057872