Skip to content

Commit 3e42809

Browse files
committed
123차 2번 문제풀이(거의 품)
1 parent 48c9bb6 commit 3e42809

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
n = int(input())
6+
lines = []
7+
for _ in range(n):
8+
x, y = map(int, input().split())
9+
lines.append([x, y])
10+
11+
lines.sort()
12+
13+
length = 0
14+
start, end = lines[0][0], lines[0][1]
15+
for i in range(1, n):
16+
if lines[i][0] <= end and lines[i][1] <= end: # 완전 겹치는 경우
17+
continue
18+
elif lines[i][0] <= end and lines[i][1] > end: # 약간 겹치는 경우 (끝점이 더 길 경우)
19+
end = lines[i][1]
20+
else: # 안 겹치는 경우
21+
length

0 commit comments

Comments
 (0)