Ishtiaq11's blog

By Ishtiaq11, history, 6 years ago, In English

Please help me to overcome time limit.

Problem Link: UVa 11340 Newspaper

My Code:

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))
 
 
 
 
  • Vote: I like it
  • -1
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Ishtiaq11 (previous revision, new revision, compare).

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Ishtiaq11 (previous revision, new revision, compare).

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Ishtiaq11 (previous revision, new revision, compare).