IT/알고리즘
[백준] 좌표압축
남갯
2024. 10. 23. 21:45
SMALL
https://www.acmicpc.net/problem/18870
fun main() = with(Scanner(System.`in`)) {
val count = nextInt()
val items = Array<Int>(count) { 0 }
for (i in 0 until count) {
items[i] = nextInt()
}
val results2 = items.copyOf()
items.sort()
val item: MutableMap<Int, Int> = mutableMapOf()
for (i in 0 until count) {
if(item[items[i]] == null){
item[items[i]] = item.size
}
}
println(results2.map { item[it] }.joinToString(" "))
}
LIST