找最大序列
来源:互联网 发布:java动物继承例子 编辑:程序博客网 时间:2024/06/06 03:07
A circus is designing a tower routine consisting of people standing atop one another’s
shoulders. For practical and aesthetic reasons, each person must be both shorter and lighter than the person below him or her. Given the heights and weights of each person in the circus, write a method to compute the largest possible number of people
in such a tower.
EXAMPLE:
Input (ht, wt): (65, 100) (70, 150) (56, 90) (75, 190) (60, 95) (68, 110)
shoulders. For practical and aesthetic reasons, each person must be both shorter and lighter than the person below him or her. Given the heights and weights of each person in the circus, write a method to compute the largest possible number of people
in such a tower.
EXAMPLE:
Input (ht, wt): (65, 100) (70, 150) (56, 90) (75, 190) (60, 95) (68, 110)
Output: The longest tower is length 6 and includes from top to bottom: (56, 90) (60,95) (65,100) (68,110) (70,150) (75,190)
struct Node{int height;int weight;Node(int h, int w): height(h), weight(w){}};bool comp(const Node &left, const Node &right){return left.height < right.height;}int fun(vector<Node> &a){int n = a.size();sort(a.begin(), a.end(), comp);int buf[n];buf[0] = 1;int result = 1;for (int i = 1; i < n; i++){buf[i] = 1;for (int j = 0; j < i; j++){if (a[i].height > a[j].height && a[i].weight > a[j].weight){buf[i] = max(buf[i], buf[j]+1);}}result = max(result, buf[i]);}return result;}
0 0
- 找最大子序列
- 找最大序列
- 10:找最大数序列
- 10_找最大数序列
- 归并分治找最大连续子序列
- noi——找最大数序列
- 找最大的斐波那契子序列
- python 找数组中最大子序列和
- noi openjudge/1.9 10:找最大数序列
- 找一个数组的最大上升子序列(允许不连续)
- 找最大子串
- 找最大方阵
- 找最大的回文
- 找最大的正方形
- 找最大元素
- 1324找最大
- 找最大的N个数
- 数组中找最大差值
- 3.Javascript语法-条件语句if...else
- 判断某一年是否是闰年
- Vue $nextTick
- 动态规划之多边形游戏
- 验证登录信息的合法性
- 找最大序列
- 欢迎使用CSDN-markdown编辑器
- 4.Javascript语法-条件语句switch
- 【Stanford-ML-Discussion】LiR,LoR,NN,SVM假设,损失函数与训练方法比较
- XML是什么,有什么作用
- Java学习日记2(一个购物车小程序)
- ROS Workspace(工作空间创建)
- 算法--水题-DNA合成
- 【剑指offer】面试题21:包含min函数的栈