Agorithm/백준 알고리즘
백준 알고리즘 17608번 막대기(python)
kimjinho1
2021. 3. 24. 22:45
728x90
반응형
기본적인 스택 문제이다.
import sys
input = sys.stdin.readline
N = int(input())
li = [int(input()) for _ in range(N)]
stack, cnt = [li.pop()], 1
for n in li[::-1]:
if stack[-1] < n:
cnt += 1
stack.append(n)
print(cnt)
728x90
반응형