[백준] 111728. 배열 합치기(실버5)

백준(실버5) - 111728. 중복 빼고 정렬하기(실버5)



풀이

BufferedReader와 BufferedWriter만 쓰면 풀리는 문제였다.
ㅠㅠ 앞으로는 System.out.println() 안써야지

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class BOJ11728 {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		int[] arr = new int[n+m];
		int idx = 0;
		
		for(int i=0; i<2; i++) {
			st = new StringTokenizer(br.readLine());
			int temp = st.countTokens();
			for(int j=0; j<temp; j++) {
				arr[idx++] = Integer.parseInt(st.nextToken());
			}
		}
		Arrays.sort(arr);
		
		for(int i=0; i<arr.length; i++) {
			bw.write(arr[i]+" ");
		}
		bw.flush();
	}

}

좋은 웹페이지 즐겨찾기