# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
549920 | DeathIsAwe | Garage (IOI09_garage) | Cpython 3 | 36 ms | 3324 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.
weights={}
rates={}
n,m=[int(i) for i in input().split()]
freepark=[i+1 for i in range(n)]
queue=[]
money=0
parking={}
for i in range(n):
rates[i+1]=int(input())
for i in range(m):
weights[i+1]=int(input())
for i in range(2*m):
car=int(input())
if car>0:
queue.append(car)
while len(freepark)>0 and len(queue)>0:
parking[queue[0]]=min(freepark)
money+=rates[min(freepark)]*weights[queue[0]]
freepark.remove(min(freepark))
del queue[0]
if car<0:
freepark.append(parking[-car])
while len(freepark)>0 and len(queue)>0:
parking[queue[0]]=min(freepark)
money+=rates[min(freepark)]*weights[queue[0]]
freepark.remove(min(freepark))
del queue[0]
print(money)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |