We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main.java.com.poogle.BOJ.Q11286; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); PriorityQueue<Integer> priorityQueue = new PriorityQueue<>((o1, o2) -> { if (Math.abs(o1) > Math.abs(o2)) return 1; else { if (Math.abs(o1) == Math.abs(o2)) return o1 - o2; else return -1; } }); /* 같은 Comparable인데 다르게 표현할 수도 있음, 절댓값이 같으면 실제 숫자 기준으로, 아니라면 절댓값을 기준으로 오름차순 정렬 PriorityQueue<Integer> queue = new PriorityQueue<>(((o1, o2) -> Math.abs(o1) == Math.abs(o2) ? Integer.compare(o1, o2) : Integer.compare(Math.abs(o1), Math.abs(o2)) )); */ for (int i = 0; i < n; i++) { int num = sc.nextInt(); if (num == 0) { if (priorityQueue.isEmpty()) System.out.println("0"); else System.out.println(priorityQueue.poll()); } else { priorityQueue.add(num); } } } }
The text was updated successfully, but these errors were encountered:
b5980eb
주석 추가
bb48b3a
Issue #219
suhyunsim
No branches or pull requests
문제
핵심 아이디어
어려운 점, 실수
풀이
The text was updated successfully, but these errors were encountered: