# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
502991 | MrVroom999 | Garage (IOI09_garage) | Pypy 3 | 159 ms | 26564 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import heapq
N, M = map(int, input().split())
rates = [int(input()) for _ in range(N)]
weights = [int(input()) for _ in range(M)]
routine = [int(input()) for _ in range(2*M)]
revenue = 0
waiting = []
available = []
for i in range(1, N + 1):
heapq.heappush(available, i)
spots = {}
for car in routine:
if car < 0:
heapq.heappush(available, spots[abs(car)])
del spots[abs(car)]
else:
waiting.append(car)
if len(waiting) and len(available):
curr = waiting.pop(0)
spot = heapq.heappop(available)
spots[curr] = spot
revenue += weights[curr - 1] * rates[spot - 1]
print(revenue)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |