필요한 내용 : 아랫 방을 윗방으로 변경하는 코드, 시작점과 끝점을 바꿔주는 코드
정답 풀이
t = int(input())
for tc in range(1,t+1):
n = int(input())
arr = []
count = [0] * 401
for _ in range(n):
arr.append(tuple(map(int,input().split())))
# print(arr)
for i in arr:
s,e = i
# 아랫방을 윗방으로 변경
if s%2 ==0: s -= 1
if e%2 ==0: e -= 1
if s > e: s, e = e, s # swap
for j in range(s,e+1):
count[j] +=1
# print(count)
print(f'#{tc} {max(count)}')
2개만 맞는 풀이
t = int(input())
for tc in range(1,t+1):
n = int(input())
arr = []
count = [0] * 401
for _ in range(n):
arr.append(tuple(map(int,input().split())))
# print(arr)
for i in arr:
s,e = i
for j in range(s,e+1):
count[j] +=1
# print(count)
print(f'#{tc} {max(count)}')
9개만 맞는 풀이
t = int(input())
for tc in range(1,t+1):
n = int(input())
arr = []
count = [0] * 401
for _ in range(n):
arr.append(tuple(map(int,input().split())))
# print(arr)
for i in arr:
s,e = i
if s > e: s, e = e, s # swap
for j in range(s,e+1):
count[j] +=1
# print(count)
print(f'#{tc} {max(count)}')
'알고리즘 문제풀이' 카테고리의 다른 글
Swea D3_11671. 기지국 Python (0) | 2024.03.02 |
---|---|
Swea D4. 반사경 Python (1) | 2024.02.29 |
백준 10157. 자리배정 Python 실버4 (2) | 2024.02.29 |
Swea D3. 화물 도크 Python 활동선택문제 (0) | 2024.02.28 |
Swea D3 배낭짐싸기(knapsack) Python 비트연산, 부분집합 (0) | 2024.02.28 |