#C7329. Total Cost of Unique Items

    ID: 51188 Type: Default 1000ms 256MiB

Total Cost of Unique Items

Total Cost of Unique Items

You are given a list of purchases, where each purchase is a pair consisting of an item name (a string) and its cost (an integer). Only the cost of the first purchase for each unique item should be considered. Your task is to compute the total cost of these unique items.

More formally, let ( n ) be the number of purchases and let ( purchases = [(s_1, c_1), (s_2, c_2), \dots, (s_n, c_n)] ) where each ( s_i ) is the name of the item and each ( c_i ) is its cost. Define a unique item as one that appears for the first time in the list; subsequent occurrences of the same item are ignored. You must output the sum of the costs ( c_i ) for each unique ( s_i ).

inputFormat

Input is given via standard input. The first line contains an integer ( n ) (the number of purchases). Each of the following ( n ) lines contains a string and an integer separated by space representing the item name and its cost respectively.

outputFormat

Output to standard output a single integer representing the total cost of the unique items.## sample

5
apple 100
banana 200
apple 150
carrot 300
banana 250
600

</p>