Skip to content

Commit 1253ffa

Browse files
JYP0824Mingguriguri
authored andcommitted
Merge pull request #7 from JYP0824/main
JYP / 3월 3주차 / 3문제
2 parents 2b235fe + 90d65a3 commit 1253ffa

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

JYP/괄호.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
a = int(input())
2+
3+
for i in range(a):
4+
res = []
5+
b = str(input())
6+
for c in b:
7+
if c == '(':
8+
res.append(c)
9+
elif c == ')':
10+
if res:
11+
res.pop()
12+
else:
13+
print("NO")
14+
break
15+
else:
16+
if len(res) == 0:
17+
print("YES")
18+
else:
19+
print("NO")

JYP/균형잡힌 세상.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
while True:
2+
a = input()
3+
4+
if a == '.':
5+
break
6+
stk = []
7+
ans = True
8+
9+
for g in a:
10+
if g =='(' or g == '[':
11+
stk.append(g)
12+
elif g == ')':
13+
if len(stk) == 0:
14+
ans = False
15+
break
16+
if stk[-1] == '(':
17+
stk.pop()
18+
else:
19+
ans=False
20+
break
21+
elif g ==']':
22+
if len(stk) == 0:
23+
ans = False
24+
break
25+
if stk[-1] == '[':
26+
stk.pop()
27+
else:
28+
ans = False
29+
break
30+
31+
32+
if ans and not stk:
33+
print("yes")
34+
else:
35+
print("no")

JYP/제로.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
num = int(input())
2+
a = []
3+
4+
for i in range(num):
5+
b = int(input())
6+
7+
if b == 0:
8+
a.pop()
9+
else:
10+
a.append(b)
11+
print(sum(a))

0 commit comments

Comments
 (0)