Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Archives
Today
Total
관리 메뉴

킹솔이

[백준/Python] 1202 보석 도둑 본문

Algorithm

[백준/Python] 1202 보석 도둑

킹솔이 2021. 1. 8. 22:56

www.acmicpc.net/problem/1202

import sys
from queue import PriorityQueue

n, k = map(int, sys.stdin.readline().split())
MV = []
C = []
for i in range(n):
    a,b = map(int, sys.stdin.readline().split())
    MV.append((a,b))
for i in range(k):
    C.append(int(sys.stdin.readline()))
MV.sort()
C.sort()
result = 0
index = 0
que = PriorityQueue()
for i in C:
    while index < n and MV[index][0] <= i:
        que.put(MV[index][1] * -1)
        index += 1
    if not que.empty():
        result += que.get()
print(-result)

설명은 일단 나중에 ..