Skip to content

Commit 8b654c7

Browse files
Merge pull request #225 from Coding-Crew-Forever/chaeryeon823/algorithm
[2025년 7월 둘째주 /chaeryeon823] 정렬
2 parents d5d5813 + b80ae5d commit 8b654c7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

chaeryeon823/BOJ_11650.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)