• 문제 링크
https://www.acmicpc.net/problem/6230
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = read(), m = read();
int[] a = new int[n], b = new int[m];
while (n-- > 0) a[n] = read();
while (m-- > 0) b[m] = read();
Arrays.sort(a);
Arrays.sort(b);
n = a.length - 1;
m = b.length - 1;
while (n >= 0 && m >= 0) if (a[n] > b[m--]) n--;
bw.write(String.valueOf(a.length * 2 - ++n));
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' 카테고리의 다른 글
[백준] 9636 NASSA’s Robot - Greedy / Java (0) | 2024.08.10 |
---|---|
[백준] 23731 Physics Experiment - Greedy / Java (0) | 2024.08.09 |
[백준] 31846 문자열 접기 - Brute Force / Java (0) | 2024.08.07 |
[백준] 11759 Bottled-Up Feelings - Brute Force / Java (0) | 2024.08.06 |
[백준] 30089 새로운 문자열 만들기 - Brute Force / Java (0) | 2024.08.05 |
댓글