problem: 11340 - newspaper
i use dict store values , characters key. read every line of input string , see if each character in every line has value in dict.
here's message tell us:
each line can 10000 characters length. aware of alargeinput size, whole inputfile 7mb.
but think ignore message above. here's code:
def main(): test_case = int(input()) t in range(test_case): number_of_paid_characters = int(input()) paid_character_dict = {} n in range(number_of_paid_characters): paid_character, value = input().split() paid_character_dict[paid_character] = int(value) paid = 0 number_of_lines = int(input()) n in range(number_of_lines): line = input() character in line: paid += paid_character_dict.get(character, 0) print("{:.2f}$".format(paid/100)) if __name__ == "__main__": main()
my output identical accepted output in udebug. udebug #11340
i think there're wrong string processing, have no idea of it.
i tried sending code several times keep getting time limit exceeded. there way improve code?
Comments
Post a Comment