• 문제 링크
https://www.acmicpc.net/problem/10689
• 풀이 코드
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));
StringBuilder sb = new StringBuilder();
Set<Integer> set = new HashSet<>();
int n = read();
for (int i = 1; i <= n; i++) {
int r = read(), max = 0;
for (int j = 1; j <= r; j++) if (set.add(read())) max = j;
sb.append("Case ").append(i).append(": ").append(max).append("\n");
set.clear();
}
bw.write(sb.toString());
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' 카테고리의 다른 글
[백준] 27100 Stamps - Graph Theory / Java (0) | 2024.05.04 |
---|---|
[백준] 15081 Is Everybody Appy? - Data Structure / Java (0) | 2024.05.03 |
[백준] 5263 samba - Data Structure / Java (0) | 2024.05.01 |
[백준] 4775 Spelling Be - Data Structure / Java (0) | 2024.04.30 |
[백준] 4649 Tanning Salon - Data Structure / Java (0) | 2024.04.29 |
댓글