Please help me to overcome time limit.
Problem Link: UVa 11340 Newspaper
My Solution:
from sys import stdin,stdout
dd = dict()
tests = int(input().strip() )
for t in range(tests):
dd.clear()
sm = 0.0
m = int(input().strip())
for x in range(m):
ch,vl = input().strip().split()
dd[ch]=float(vl)
for x in range(int(input())):
line=input()
for letter in line:
if letter in dd:
sm += dd[letter]
print('%0.2f$' %(sm/100.0))