
2025.04.17
오늘한 내용 : 파이썬을 잊지 않기 위한 백준 풀이 2문제
WEEK06: 메모리 누수, 균형 이진 탐색 트리(AVL Tree, Red-Black Tree)
오랜만에 파이썬하니까 힘들다 힘들어! 분명히 실랜디 문제인데 왜 이렇게 안풀릴까
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
p = []
for _ in range(m):
p.append(int(input().strip()))
p.sort(reverse=True)
max_result = 0
max_price = 0
for i,price in enumerate(p):
if i+1 <= n:
if max_result < price * (i+1):
max_result = price* (i+1)
max_price = price
if i+1 == n:
break
print(max_price, max_result)
import sys
input = sys.stdin.readline
N = int(input().strip())
E = int(input().strip())
song = [set() for _ in range(N+1)]
for i in range(E):
data = list(map(int,input().split()))
cnt, people = data[0], data[1:]
if 1 in people:
for p in people:
song[p].add(i)
else:
# 해당 그룹의 모든 사람들의 노래 정보 공유
shared = set()
for p in people:
shared |= song[p]
for p in people:
song[p] = shared.copy()
song[p].add(i)
for i in range(1, N+1):
if song[1].issubset(song[i]):
print(i)