| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1366714 | makon | Grilled Bottle (KAISTRUN26SPRING_D) | Pypy 3 | 2157 ms | 357764 KiB |
import sys, heapq
input = sys.stdin.readline
def main():
n, m = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(n)]
b = list(map(int, input().split()))
a.sort(reverse=True)
def f(k, flag=False):
c = b[:k]
c.sort(reverse=True)
h = []
j = 0
s = 0
for x in c:
while j < n and a[j][0] >= x:
heapq.heappush(h, -a[j][1])
j += 1
if not h:
return (False, 0) if flag else False
s -= heapq.heappop(h)
return (True, s) if flag else True
l, r = 0, min(n, m)
while l < r:
mid = (l + r + 1) // 2
if f(mid):
l = mid
else:
r = mid - 1
_, ans = f(l, True)
print(l, ans)
if __name__ == "__main__": main()Compilation message (stdout)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
