본문 바로가기
알고리즘 & 자료구조/백준

백준 5619

by 신재권 2022. 1. 11.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main5619 {

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine()); // 수의 개수 N
	
		int[] num = new int[N];
		for(int i=0; i<N; i++) {
			num[i] = Integer.parseInt(br.readLine());
		}
		
		Arrays.sort(num);   //정렬 
		
		// 6개까지 정렬하면 된다 
		int[] ans = new int[6];

		int s = 0;
		for(int i=0; i<N; i++) {
			for(int j=i+1; j<N; j++) {
				if(s==6) break;
				ans[s++] = Integer.parseInt(num[i]+""+num[j]);
				ans[s++] = Integer.parseInt(num[j]+""+num[i]);
			}
		}

		Arrays.sort(ans);
		
		System.out.println(ans[2]);
		
	}
		
	
}

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 21758  (0) 2022.01.13
백준 3976  (0) 2022.01.12
백준 1455  (0) 2022.01.10
백준 4055  (0) 2022.01.09
백준 5911  (0) 2022.01.08