• 문제 링크
https://www.acmicpc.net/problem/8669
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.HashSet;
import java.util.Set;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
Set<Integer> set = new HashSet<>();
int n = read();
while (n-- > 0) {
read();
set.add(read());
}
bw.write(String.valueOf(set.size()));
bw.flush();
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 27590 Sun and Moon - Brute Force / Java (0) | 2024.10.25 |
---|---|
[백준] 24817 Competitive Arcade Basketball - Data Structure / Java (0) | 2024.10.24 |
[백준] 27160 할리갈리 - Data Structure / Java (0) | 2024.10.22 |
[백준] 6513 Deli Deli - Data Structure / Java (0) | 2024.10.21 |
[백준] 17048 Jarvis - Data Structure / Java (0) | 2024.10.20 |
댓글