Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bba50cd

Browse files
committed
고다혜: [PG] 181188 요격 시스템_241115
1 parent ffce1db commit bba50cd

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

‎Programmers/Level2/DH_181188.java‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import java.util.*;
2+
3+
/*
4+
* 요격 시스템
5+
*/
6+
7+
public class DH_181188 {
8+
static int solution(int[][] targets) {
9+
int answer = 0;
10+
11+
PriorityQueue<int[]> q = new PriorityQueue<>((o1, o2) -> {
12+
if(o1[1] != o2[1]) return Integer.compare(o1[1], o2[1]);
13+
return Integer.compare(o1[0], o2[0]);
14+
});
15+
16+
for(int[] target: targets) q.add(target);
17+
18+
int missile = Integer.MIN_VALUE;
19+
while(!q.isEmpty()) {
20+
int[] current = q.poll();
21+
if(missile <= current[0]) {
22+
missile = current[0];
23+
answer += 1;
24+
}
25+
}
26+
return answer;
27+
}
28+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /