Skip to content

Commit d240039

Browse files
committed
[Silver IV] Title: 제로, Time: 184 ms, Memory: 16976 KB -BaekjoonHub
1 parent 38e13a1 commit d240039

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

백준/Silver/10773. 제로/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
### 성능 요약
66

7-
메모리: 31900 KB, 시간: 88 ms
7+
메모리: 16976 KB, 시간: 184 ms
88

99
### 분류
1010

11-
자료 구조, 구현, 스택
11+
구현, 자료 구조, 스택
1212

1313
### 제출 일자
1414

15-
2024년 4월 12일 11:20:30
15+
2026년 3월 5일 17:45:00
1616

1717
### 문제 설명
1818

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// /dev/stdin
2+
const input = require("fs")
3+
.readFileSync("/dev/stdin")
4+
.toString()
5+
.trim()
6+
.split("\n")
7+
.map((x) => x.replace("\r", ""));
8+
9+
const N = Number(input[0]);
10+
11+
const stack = [];
12+
13+
for (let i = 1; i <= N; i++) {
14+
if (input[i] == 0) {
15+
stack.pop();
16+
} else {
17+
stack.push(Number(input[i]));
18+
}
19+
}
20+
21+
console.log(stack.reduce((acc, cur) => acc + cur, 0));

0 commit comments

Comments
 (0)