-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha65_q1_tower_defence.py
57 lines (40 loc) · 962 Bytes
/
a65_q1_tower_defence.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
n,m,k,w = [int(i) for i in input().strip().split()]
monsList = [int(i) for i in input().strip().split()]
monsPow = [int(i) for i in input().strip().split()]
towList = [int(i) for i in input().strip().split()]
sumPow = sum(monsPow)
monsDict = {}
for i in range(len(monsList)):
if monsList[i] not in monsDict.keys():
monsDict[monsList[i]] = monsPow[i]
else:
monsDict[monsList[i]] += monsPow[i]
#print( monsDict )
#monsDict = collections.OrderedDict(sorted(monsDict.items()))
monsDict = dict(sorted(monsDict.items()))
towList.sort()
#print( monsDict )
#print( towList )
for i in towList:
for j in range( max( 0,i-w ) , min( i+w+1,n ) ):
if j in monsDict.keys() and monsDict[j] > 0:
#print("thtis")
monsDict[j] -= 1
#print( monsDict[j] )
sumPow -= 1
break
print(sumPow)
'''
100 3 3 1
80 70 60
1 1 1
70 71 69
10 1 2 4
1
10
2 5
10 1 2 1
1
10
2 5
'''