일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- Python
- mvc
- pypy3
- appendleft
- LCM
- JPA
- C#강의
- 백준
- c#
- 완전탐색
- unity
- 소수찾기
- 합 구하기
- DP
- 파이썬
- 우선순위큐
- 누적합
- 인프런
- 프로그래머스
- python3
- spring
- BFS
- 연관관계
- 그리디 알고리즘
- Java
- 소수판별
- 브루투포스
- deque
- popleft
- 1일1솔
Archives
- Today
- Total
jae_coding
(백준 자료구조 문제풀이)10799번 쇠막대기 본문
반응형
문제
코드
import sys
from collections import deque
input = sys.stdin.readline
input_string = deque(input().strip())
count = 0
result = 0
primary_string = ""
while len(input_string) != 0:
temp = input_string.pop()
if temp == ")":
count += 1
else:
if primary_string == "(":
count -= 1
result += 1
else:
count -= 1
result += count
primary_string = temp
print(result)
반응형
'알고리즘 문제 > 자료구조 문제' 카테고리의 다른 글
(백준 자료구조 문제풀이) 2504번 괄호의 값 (0) | 2022.07.20 |
---|---|
(백준 자료구조 문제풀이) 2346번 풍선 터트리기 (0) | 2022.07.19 |
(백준 자료구조 문제풀이) 1935번 후위 표기식2 (0) | 2022.07.19 |
(백준 자료구조 문제풀이) 1874번 스택 수열 (0) | 2022.07.19 |
(백준 자료구조 문제풀이) 10866번 덱 (0) | 2022.07.18 |
Comments