https://www.acmicpc.net/problem/1781
heapq를 잘 사용해서 최대 컵라면 개수를 구해준다.
import heapq
n = int(input())
arr = []
for _ in range(n):
a, b = map(int, input().split())
arr.append((a, b))
arr.sort()
heap = []
for deadline, cups in arr:
heapq.heappush(heap, cups)
if len(heap) > deadline:
heapq.heappop(heap)
print(sum(heap))
'알고리즘 문제풀이' 카테고리의 다른 글
국왕의 방문[백준 2982] (0) | 2025.01.05 |
---|---|
최소 회의실 개수 [백준 19598] (0) | 2024.10.03 |
URLs [백준 6324] (0) | 2024.09.23 |
Šifra [백준 20959] (0) | 2024.09.22 |
늑대와 올바른 단어[백준 13022] (1) | 2024.09.22 |