728x90
https://www.acmicpc.net/problem/11651
package BAEKJOON.Silver.Ⅴ;
import java.util.Arrays;
import java.util.Scanner;
public class NO11651 {
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++) {
arr[i][0] = sc.nextInt();
arr[i][1] = sc.nextInt();
}
// System.out.println(Arrays.deepToString(arr));
Arrays.sort(arr, (o1, o2) -> {
if(o1[1] == o2[1]) {
return o1[0] - o2[0];
} else {
return o1[1] - o2[1];
}
});
for (int[] nums : arr) {
System.out.print(nums[0] + " " + nums[1]);
System.out.println();
}
}
}
728x90
'Algorithm & SQL > BAEKJOON' 카테고리의 다른 글
백준 JAVA 1874 스택 수열 (0) | 2022.08.12 |
---|---|
백준 JAVA 4949 균형잡힌 세상 (0) | 2022.08.11 |
백준 JAVA 11650 좌표 정렬하기 (0) | 2022.08.11 |
백준 10816 JAVA 숫자 카드2 (0) | 2022.08.10 |
백준 JAVA 15829 Hashing (0) | 2022.08.10 |
댓글