File tree Expand file tree Collapse file tree
백준/Silver/7785. 회사에 있는 사람 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments