-
Notifications
You must be signed in to change notification settings - Fork 3
/
Main.java
58 lines (46 loc) ยท 1.74 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package dev.idion.baekjoon.newrecruits;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int repeat = Integer.parseInt(br.readLine());
StringBuilder sb = new StringBuilder();
for (int i = 0; i < repeat; i++) { // ์
๋ ฅ ๊ฐ์๋งํผ ๋ฐ๋ณต
int count = Integer.parseInt(br.readLine()); // ์ธ์ ์
Recruit[] recruits = new Recruit[count];
for (int j = 0; j < count; j++) { // ์ง์์ ์์ฑ
StringTokenizer st = new StringTokenizer(br.readLine());
recruits[j] = new Recruit(st.nextToken(), st.nextToken());
}
Arrays.sort(recruits); // ์๋ฅ ์์์ ๋ฐ๋ผ ์ ๋ ฌ
int pass = 1;
int minInterviewRank = recruits[0].interviewRank;
Recruit cur;
for (int j = 1; j < count; j++) {
cur = recruits[j];
if (cur.interviewRank < minInterviewRank) { // ์ธํฐ๋ทฐ ์์๊ฐ ํ์ฌ๊น์ง ๋์จ ์ธํฐ๋ทฐ ์์๋ณด๋ค ๋๋ค๋ฉด
pass++; // ํฉ๊ฒฉ
minInterviewRank = cur.interviewRank;
}
}
sb.append(pass).append("\n");
}
System.out.print(sb.deleteCharAt(sb.lastIndexOf("\n")));
}
private static class Recruit implements Comparable<Recruit> {
private int paperRank;
private int interviewRank;
public Recruit(String paper, String interview) {
this.paperRank = Integer.parseInt(paper);
this.interviewRank = Integer.parseInt(interview);
}
@Override
public int compareTo(Recruit o) {
return this.paperRank - o.paperRank;
}
}
}