Submission #549920

# Submission time Handle Problem Language Result Execution time Memory
549920 2022-04-16T20:54:14 Z DeathIsAwe Garage (IOI09_garage) Python 3
100 / 100
36 ms 3324 KB
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
1 Correct 16 ms 2936 KB Output is correct
2 Correct 13 ms 2812 KB Output is correct
3 Correct 15 ms 2920 KB Output is correct
4 Correct 16 ms 2900 KB Output is correct
5 Correct 16 ms 2896 KB Output is correct
6 Correct 14 ms 2900 KB Output is correct
7 Correct 15 ms 2832 KB Output is correct
8 Correct 20 ms 2900 KB Output is correct
9 Correct 15 ms 2900 KB Output is correct
10 Correct 21 ms 2900 KB Output is correct
11 Correct 20 ms 2832 KB Output is correct
12 Correct 16 ms 2864 KB Output is correct
13 Correct 17 ms 2992 KB Output is correct
14 Correct 20 ms 3072 KB Output is correct
15 Correct 22 ms 3100 KB Output is correct
16 Correct 24 ms 3096 KB Output is correct
17 Correct 26 ms 3196 KB Output is correct
18 Correct 28 ms 3308 KB Output is correct
19 Correct 29 ms 3324 KB Output is correct
20 Correct 36 ms 3296 KB Output is correct