package learn.stream_tset;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;
public class Q1 {
public static void main(String[] args) {
PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(
new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
return o2.compareTo(o1);
}
}
);
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
for (int i = 0; i < n; i++) {
priorityQueue.offer(scanner.nextInt());
}
for (int i = 0; i < 3; i++) {
System.out.println(priorityQueue.poll());
}
}
}
PriorityQueue的自定义排序
最新推荐文章于 2024-08-15 14:47:41 发布