[백준/코틀린] 1541번: 잃어버린 괄호
실버 2
링크
풀이
모든 + 연산을 먼저 계산한 뒤, - 연산을 적용하면 최솟값을 얻을 수 있습니다.
코드
1
2
3
4
5
6
fun main() = println(
readln().split("-")
.map { it.split("+").sumOf(String::toInt) }
.reduce(Int::minus)
)
This post is licensed under CC BY 4.0 by the author.