• Home
  • About
    • Moon photo

      Moon

      개발자는 자고 싶다.

    • Learn More
    • Twitter
    • Facebook
    • Instagram
    • Github
    • Steam
  • Posts
    • All Posts
    • All Tags
  • Projects

백준 - 10773 제로

07 Jun 2022

Reading time ~1 minute

문제

10773 제로

screencapture

답

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())
}


baekjoonkotlin코틀린백준실버구현자료 구조스택 Share Tweet +1