We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents d5d5813 + b80ae5d commit 8b654c7Copy full SHA for 8b654c7
1 file changed
chaeryeon823/BOJ_11650.js
@@ -0,0 +1,31 @@
1
+const readline = require("readline");
2
+
3
+const rl = readline.createInterface({
4
+ input: process.stdin,
5
+ output: process.stdout,
6
+});
7
8
+const input = [];
9
+rl.on("line", (line) => {
10
+ input.push(line.trim());
11
+}).on("close", () => {
12
+ const N = parseInt(input[0]);
13
+ const xy = [];
14
15
+ for (let i = 1; i <= N; i++) {
16
+ const [x, y] = input[i].split(" ").map(Number);
17
+ xy.push([x, y]);
18
+ }
19
20
+ xy.sort((a, b) => {
21
+ if (a[0] === b[0]) {
22
+ return a[1] - b[1]; // x가 같으면 y 오름차순
23
+ } else {
24
+ return a[0] - b[0]; // x 오름차순
25
26
+ });
27
28
+ for (let i = 0; i < N; i++) {
29
+ console.log(xy[i][0] + " " + xy[i][1]);
30
31
0 commit comments