๋ฌธ์
https://www.acmicpc.net/problem/1202
ํ์ด
# ๋ฐฑ์ค 1202๋ฒ ๋ฌธ์ - ๋ณด์ ๋๋
import sys, heapq
input = sys.stdin.readline
n, k = map(int, input().split())
jewelry = [list(map(int, input().split())) for _ in range(n)]
bags = [int(input()) for _ in range(k)]
jewelry.sort()
bags.sort()
tmp = []
result = 0
for bag in bags:
while jewelry and bag >= jewelry[0][0]:
heapq.heappush(tmp, -jewelry[0][1])
heapq.heappop(jewelry)
if tmp:
result += heapq.heappop(tmp)
elif not jewelry:
break
print(-result)
'๐๏ธ Algorithm > ๐ฉ ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ฉ [๋ฐฑ์ค] [Python] [Gold4] 2636๋ฒ_์น์ฆ (0) | 2023.03.31 |
---|---|
๐ฉ [๋ฐฑ์ค] [Python] [Gold4] 1744๋ฒ_์ ๋ฌถ๊ธฐ (0) | 2023.03.31 |
๐ฉ [๋ฐฑ์ค] [Python] [Gold4] 1715๋ฒ_์นด๋ ์ ๋ ฌํ๊ธฐ (0) | 2023.03.28 |
๐ฉ [๋ฐฑ์ค] [Python] [Silver1] 11660๋ฒ_๊ตฌ๊ฐ ํฉ ๊ตฌํ๊ธฐ 5 (0) | 2023.03.25 |
๐ฉ [๋ฐฑ์ค] [Python] [Silver2] 18111๋ฒ_๋ง์ธํฌ๋ํํธ (0) | 2023.03.20 |