Submission #502991

# Submission time Handle Problem Language Result Execution time Memory
502991 2022-01-06T21:15:31 Z MrVroom999 Garage (IOI09_garage) PyPy 3
100 / 100
159 ms 26564 KB
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
1 Correct 36 ms 18212 KB Output is correct
2 Correct 41 ms 18340 KB Output is correct
3 Correct 35 ms 18216 KB Output is correct
4 Correct 37 ms 18216 KB Output is correct
5 Correct 36 ms 18256 KB Output is correct
6 Correct 37 ms 18292 KB Output is correct
7 Correct 37 ms 18196 KB Output is correct
8 Correct 43 ms 18296 KB Output is correct
9 Correct 39 ms 18308 KB Output is correct
10 Correct 52 ms 18296 KB Output is correct
11 Correct 62 ms 19104 KB Output is correct
12 Correct 70 ms 19516 KB Output is correct
13 Correct 89 ms 20080 KB Output is correct
14 Correct 117 ms 24456 KB Output is correct
15 Correct 121 ms 25408 KB Output is correct
16 Correct 145 ms 26156 KB Output is correct
17 Correct 157 ms 26564 KB Output is correct
18 Correct 159 ms 26288 KB Output is correct
19 Correct 120 ms 25504 KB Output is correct
20 Correct 153 ms 26268 KB Output is correct