Skip to content

Commit 57ec8ad

Browse files
committed
114차 2번 문제 다시 풀이
1 parent bfde30d commit 57ec8ad

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

live11/test114/문제2/박희경.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@
1010
radius.append((x-r, x+r))
1111

1212
radius.sort()
13+
1314
flag = 'YES'
14-
for i in range(len(radius) - 1):
15-
if radius[i][0] < radius[i+1][0]:
16-
if radius[i][1] > radius[i+1][1]: # 안에 있는 경우
17-
continue
18-
else:
15+
stack = []
16+
for start, end in radius:
17+
if not stack:
18+
stack.append((start, end))
19+
else:
20+
pre_start, pre_end = stack.pop()
21+
if pre_start >= start or pre_end == start: # 맞닿아 있을 때
1922
flag = 'NO'
20-
if radius[i][1] < radius[i+1][0]:
21-
continue
22-
23-
print(flag)
23+
break
24+
if pre_end > start and pre_end <= end: # 겹칠 때
25+
flag = 'NO'
26+
break
27+
print(flag)

0 commit comments

Comments
 (0)