Skip to content

Commit

Permalink
백준/단계별: 회사에 있는 사람 문제풀이 (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
sieunnnn committed Sep 29, 2023
1 parent 51f5749 commit e52f8e0
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/baekjoon/step/setsAndMap/PROB7785.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package baekjoon.step.setsAndMap;

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

public class PROB7785 {
// 회사에 남아 있는 사람 구하고 사전순의 역순으로 출력

static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
static HashMap<String, String> map = new HashMap<>();
static List<String> names = new ArrayList<>();
static int N;
static String name;
static String status;


public static void main(String[] args) throws IOException {
N = Integer.parseInt(br.readLine());
for (int i = 0; i < N; i ++) {
st = new StringTokenizer(br.readLine());
name = st.nextToken();
status = st.nextToken();

if (map.containsKey(name)) {
map.remove(name);
} else {
map.put(name, status);
}
}

map.forEach((key, value) -> names.add(key));

names.sort(Collections.reverseOrder());

for (String name : names) {
System.out.println(name);
}
}
}

0 comments on commit e52f8e0

Please sign in to comment.