Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
---|---|---|---|---|---|---|
![]() | Accepted | Python | 0.280 | 0.000 | 1409 | 2 hours ago |
def f(total, com, rs):
if com == ' <= ':
return total <= rs
elif com == ' >= ':
return total >= rs
elif com == ' = ':
return total == rs
elif com == ' < ':
return total < rs
else:
return total > rs
p, q = map(int, input().split())
d = {}
for _ in range(p):
x, y = input().split()
d[x] = int(float(y)*10)
cnt = 1
b = [' < ', ' > ', ' <= ', ' >= ', ' = ']
for _ in range(q):
a = list(input().split(' + '))
com = None
rs = 0
for c in b:
if (c in a[-1]):
rs = int(a[-1].split(c)[1])*10
a[-1] = a[-1].split(c)[0]
com = c
total = 0
for x in a:
total += d[x]
if f(total, com, rs):
print(f"Guess #{cnt} was correct.")
else:
print(f"Guess #{cnt} was incorrect.")
cnt += 1
No comments:
Post a Comment