Skip to content

Commit

Permalink
Merge pull request #53 from AlgoLeadMe/17-suhyun113
Browse files Browse the repository at this point in the history
17-suhyun113
  • Loading branch information
suhyun113 authored Oct 8, 2024
2 parents 85daad0 + 12fb0e1 commit cc8c5c0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion suhyun113/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
| 10μ°¨μ‹œ | 2024.07.13 | ν”Œλ‘œμ΄λ“œ-μ›Œμ…œ | [ν”Œλ‘œμ΄λ“œ](https://www.acmicpc.net/problem/11404) | [#36](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/36) |
| 11μ°¨μ‹œ | 2024.07.16 | BFS | [μ—°κ΅¬μ†Œ](https://www.acmicpc.net/problem/14502) | [#39](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/39) |
| 12μ°¨μ‹œ | 2024.07.24 | 이뢄 탐색 | [λ‚˜λ¬΄ 자λ₯΄κΈ°](https://www.acmicpc.net/problem/2805) | [#42](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/42) |
| 16μ°¨μ‹œ | 2024.09.13 | 그리디 | [동전 0](https://www.acmicpc.net/problem/11047) | [#49](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/49) |
| 16μ°¨μ‹œ | 2024.09.13 | 그리디 | [동전 0](https://www.acmicpc.net/problem/11047) | [#49](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/49) |
| 17μ°¨μ‹œ | 2024.09.22 | μŠ€νƒ | [μŠ€νƒ μˆ˜μ—΄](https://www.acmicpc.net/problem/1874) | [#53](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/53) |
29 changes: 29 additions & 0 deletions suhyun113/μŠ€νƒ/17-suhyun113.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 1874 : μŠ€νƒ μˆ˜μ—΄

n = int(input()) # μˆ˜μ—΄μ˜ 크기
sequence = [int(input()) for _ in range(n)] # 주어진 μˆ˜μ—΄

stack = []
result = []
current = 1 # μŠ€νƒμ— 넣을 숫자
possible = True

for num in sequence:
# ν˜„μž¬ μˆ«μžλ³΄λ‹€ μˆ˜μ—΄μ—μ„œ ν•„μš”ν•œ μˆ«μžκ°€ ν¬κ±°λ‚˜ 같을 λ•ŒκΉŒμ§€ push
while current <= num:
stack.append(current)
result.append('+')
current += 1

# μŠ€νƒμ˜ μ΅œμƒλ‹¨μ΄ numκ³Ό κ°™λ‹€λ©΄ pop
if stack and stack[-1] == num:
stack.pop()
result.append('-')
else:
possible = False
break

if possible:
print("\n".join(result))
else:
print("NO")

0 comments on commit cc8c5c0

Please sign in to comment.