728x90
https://www.acmicpc.net/problem/11650
package BAEKJOON.Silver.Ⅴ;
import java.util.Arrays;
import java.util.Scanner;
public class NO11650 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[][] arr = new int[n][2];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 2; j++) {
arr[i][j] = sc.nextInt();
}
}
// System.out.println(Arrays.deepToString(arr));
Arrays.sort(arr, (o1, o2) -> {
if (o1[0] == o2[0]) {
return o1[1] - o2[1];
} else {
return o1[0] - o2[0];
}
});
// System.out.println(Arrays.deepToString(arr));
for (int[] ints : arr) {
System.out.print(ints[0] + " " + ints[1]);
System.out.println();
}
}
}
728x90
'Algorithm & SQL > BAEKJOON' 카테고리의 다른 글
백준 JAVA 4949 균형잡힌 세상 (0) | 2022.08.11 |
---|---|
백준 JAVA 11651 좌표 정렬하기2 (0) | 2022.08.11 |
백준 10816 JAVA 숫자 카드2 (0) | 2022.08.10 |
백준 JAVA 15829 Hashing (0) | 2022.08.10 |
백준 JAVA 1436 영화감독 숌 (0) | 2022.08.10 |
댓글