문제
10773 제로
답
kotlin code
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())
}