
요게 우선순위 큐를 이용해서 풀 수 있는 문제중에 하나인데,
문제를 보면 그런 의문이 든다.
"조건이 여러개면 어떡하지?"
근데 이 야무진 파이썬이 튜플로 값을 넣었을때 앞에 있는 값을 먼저 확인해서 정렬을 알아서 한단다.
그럼 이제 이 문제를 해결 할 수 있다.
import heapq
n,m=map(int,input().split())
ary=[]
for _ in range(n):
x,y=map(int,input().split())
heapq.heappush(ary,(x+y,x,y))
for _ in range(m):
sum_value,x,y=heapq.heappop(ary)
x+=2
y+=2
heapq.heappush(ary,(x+y,x,y))
sum_value,x,y=heapq.heappop(ary)
print(x,y)