Home 백준 - 10773 제로
Post
Cancel

백준 - 10773 제로

문제

10773 제로

screencapture

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.

백준 - 2675 문자열 반복

백준 - 1712 손익분기점