-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path08p1.py
33 lines (30 loc) · 822 Bytes
/
08p1.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
from fileinput import input
data = input("8.txt")
variables = {}
def compare(x,y,sign):
if sign=="==":
return x==y
elif sign=="<=":
return x<=y
elif sign==">=":
return x>=y
elif sign==">":
return x>y
elif sign=="<":
return x<y
elif sign=="!=":
return x!=y
for row in data:
splited = row.strip().split()
if splited[4] not in variables:
variables[splited[4]] = 0
if compare(variables[splited[4]],int(splited[6]),splited[5]):
if splited[0] not in variables:
variables[splited[0]] = 0
if splited[1] == "dec":
variables[splited[0]]-=int(splited[2])
else:
variables[splited[0]]+=int(splited[2])
else:
continue
print(variables[max(variables,key=variables.get)])