Skip to content

Commit bb1f6b9

Browse files
committed
[Silver V] Title: 회사에 있는 사람, Time: 508 ms, Memory: 44760 KB -BaekjoonHub
1 parent 380a484 commit bb1f6b9

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

백준/Silver/7785. 회사에 있는 사람/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
### 성능 요약
66

7-
메모리: 53440 KB, 시간: 556 ms
7+
메모리: 44760 KB, 시간: 508 ms
88

99
### 분류
1010

1111
자료 구조, 집합과 맵, 해시를 사용한 집합과 맵
1212

1313
### 제출 일자
1414

15-
2025년 11월 1일 16:52:08
15+
2025년 11월 1일 16:55:13
1616

1717
### 문제 설명
1818

백준/Silver/7785. 회사에 있는 사람/회사에 있는 사람.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ public static void main(String[] args) throws IOException{
1111
Set<String> set = new TreeSet<>(Collections.reverseOrder());
1212

1313
while(n-- > 0){
14-
String[] s = br.readLine().split(" ");
15-
if(s[1].equals("enter")) set.add(s[0]);
16-
else set.remove(s[0]);
14+
// String[] s = br.readLine().split(" ");
15+
StringTokenizer st = new StringTokenizer(br.readLine());
16+
String name = st.nextToken();
17+
String cmd = st.nextToken();
18+
if(cmd.equals("enter")) set.add(name);
19+
else set.remove(name);
1720
}
1821

1922
// List<String> al = new ArrayList<>(set);
@@ -22,10 +25,11 @@ public static void main(String[] args) throws IOException{
2225
// for(String s : al){
2326
// sb.append(s).append("\n");
2427
// }
25-
for(String s : set){
26-
sb.append(s).append("\n");
27-
}
28+
// for(String s : set){
29+
// sb.append(s).append("\n");
30+
// }
2831

32+
set.forEach(s -> sb.append(s).append("\n"));
2933
System.out.print(sb);
3034
}
3135
}

0 commit comments

Comments
 (0)