코딩테스트/백준
[백준-자바] 11728번 배열 합치기 / 2022.06.04
강원대목동녀
2022. 6. 4. 19:07
https://www.acmicpc.net/problem/11728
import java.io.*;
import java.util.*;
public class Main {
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());
st = new StringTokenizer(br.readLine());
int [] number = new int [N+M];
for(int i=0; i<N; i++) { // 0 1
number[i] = Integer.parseInt(st.nextToken());
}
st = new StringTokenizer(br.readLine());
for(int i=N; i<N+M; i++){ // 2 3
number[i] = Integer.parseInt(st.nextToken());
}
Arrays.sort(number);
for(int i:number)
bw.write(i+" ");
bw.flush();
bw.close();
br.close();
}
}
* BufferedWriter를 사용하면 시간초과가 나지않는다.