백준 - 10773 제로
문제
10773 제로
답
kotlin code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.util.*
fun main() {
q10773()
}
fun q10773() = with(Scanner(System.`in`)) {
val inputs = List(nextInt()) {nextInt()}
val stack = Stack<Int>()
for (input in inputs) {
if(input == 0) stack.pop()
else stack.push(input)
}
println(stack.sum())
}
This post is licensed under CC BY 4.0 by the author.