# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
502991 | MrVroom999 | Garage (IOI09_garage) | Pypy 3 | 159 ms | 26564 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
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... |