공부기록/백준

[백준] 18310번 안테나

메델 2023. 11. 21. 05:21
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner kb = new Scanner(System.in);
    	int n = kb.nextInt();
    	int[] location = new int[n];

    	
    	for(int i=0; i<n; i++) {
    		location[i] = kb.nextInt();
    	}
    	
    	Arrays.sort(location);
    	
    	int length = location.length;
    	
    	if(length%2 != 0) {
    		System.out.println(location[length/2]);
    	}else {
    		System.out.println(location[length/2-1]);
    	}
    }
}