시배's Android
Algorithm | 백준 Kotlin 3273 두 수의 합 본문
private fun main() {
val n = readLine()!!.toInt()
val a = readLine()!!.split(" ").map{ it.toInt() }
val x = readLine()!!.toInt()
val f = a.groupBy{ it }.map{ (a, b) -> a to b.size }.toMap()
println(f.map{ (y, c) -> c.toLong() * f.getOrElse(x - y) { 0 } }.sum() / 2)
}
'Algorithm' 카테고리의 다른 글
Algorithm | 백준 Kotlin 12101 1,2,3 더하기 2 (0) | 2023.10.07 |
---|---|
Algorithm | 백준 Kotlin 5548 행성 탐사 (0) | 2023.10.07 |
Algorithm | 백준 Kotlin 6443 애너그램 (0) | 2023.09.23 |
Algorithm | 백준 Kotlin 2553 마지막 팩토리얼 수 (0) | 2023.09.23 |
Algorithm | 백준 Kotlin 1158 요세푸스 문제 (0) | 2023.09.23 |