-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
31 lines (24 loc) · 714 Bytes
/
Main.java
File metadata and controls
31 lines (24 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.Scanner;
import java.util.Arrays;
public class Main {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int[][] arr = new int[N][2];
for(int i = 0; i < N; i++){
arr[i][0] = in.nextInt();
arr[i][1] = in.nextInt();
}
Arrays.sort(arr, (e1, e2) -> {
if(e1[0] == e2[0]){
return Integer.compare(e1[1], e2[1]);
} else {
return Integer.compare(e1[0], e2[0]);
}
});
for(int i=0; i < N; i++){
System.out.println(arr[i][0] + " " + arr[i][1]);
}
in.close();
}
}