IT/알고리즘
[백준] 11651번 좌표정렬하기_2
남갯
2024. 12. 9. 21:07
728x90
SMALL
https://www.acmicpc.net/problem/11651
fun main() = with(Scanner(System.`in`)) {
val size = nextInt()
val array: MutableList<Position> = mutableListOf()
for (i in 0 until size) {
val x = nextInt()
val y = nextInt()
array.add(Position(x, y))
}
array.sortedWith(compareBy({ it.y }, { it.x }))
.forEach { println("${it.x} ${it.y}") }
}
data class Position(val x: Int, val y: Int)
728x90
LIST