Skip to content

Commit b45b494

Browse files
committed
[BOJ] 보석 도둑 / 골드2 / 80분 실패
https://www.acmicpc.net/problem/1202
1 parent 9cb11b9 commit b45b494

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import sys
2+
import heapq
3+
4+
N, K = map(int, sys.stdin.readline().split())
5+
jewels = []
6+
for _ in range(N):
7+
heapq.heappush(jewels, list(map(int, sys.stdin.readline().split())))
8+
bags = []
9+
for _ in range(K):
10+
bags.append(int(sys.stdin.readline()))
11+
bags.sort()
12+
13+
answer = 0
14+
tmp_jew = []
15+
for bag in bags:
16+
while jewels and bag >= jewels[0][0]:
17+
heapq.heappush(tmp_jew, -heapq.heappop(jewels)[1])
18+
if tmp_jew:
19+
answer -= heapq.heappop(tmp_jew)
20+
elif not jewels:
21+
break
22+
print(answer)

0 commit comments

Comments
 (0)