﻿ #yyds干货盘点# 解决名企真题：马戏团 - 鸿网互联

# #yyds干货盘点# 解决名企真题：马戏团

1.简述： 描述 搜狐员工小王最近利用假期在外地旅游，在某个小镇碰到一个马戏团表演，精彩的表演结束后发现团长正和大伙在帐篷前激烈讨论，小王打听了下了解到， 马戏团正打算

1.简述：

6
1 65 100
2 75 80
3 80 100
4 60 95
5 82 101
6 81 70

4

2.代码实现：

import java.io.IOException;
import java.util.*;

public class Main {
public static void main(String[] args) throws IOException {
SH1();
}
static class Persion{
public int id;
public int weight;
public int height;

}
public static void SH1() throws IOException {
String ln;
while ((ln = br.readLine()) != null){
List<Persion> personList = new ArrayList<>();
int n = Integer.parseInt(ln);
int[] p = new int[n];
for (int i = 0; i < n; i++) {
int id = Integer.parseInt(str[0]);
int weight = Integer.parseInt(str[1]);
int heigth = Integer.parseInt(str[2]);
Persion persion = new Persion();
persion.id = id;
persion.weight = weight;
persion.height = heigth;
}
personList.sort((a,b)->{
if (a.weight - b.weight == 0){
return b.height - a.height;
}
return a.weight - b.weight;
});
int size = personList.size();
for (int i = 1; i < size; i++) {
for (int j = i - 1 ; j >= 0; j--) {
if (personList.get(j).height <= personList.get(i).height){
if (p[i] < p[j] + 1){
p[i] = p[j] + 1;
}
}
}
}
int max = 0;
for (int i = 0; i < n; i++) {
if (p[i] > max) {
max = p[i];
}
}
System.out.println(max+1);
}

}
}

<