Slot Machine
Time limit2sMemory limit1024 MB
Given a table of winning combinations with prizes and m machine results, find the net change in capital when each game costs 10 rubles.
- Level
Easy2 of 10
- Topics
- Hash map, Implementation
- Solved
- No attempts yet
Problem
A new slot machine was recently installed in a game arcade in one of the remote corners of our country. It works simply: insert a token (costing 10 rubles) and pull the lever, after which four digits appear on the screen. So each game on the machine costs 10 rubles.
A table of winning combinations determines whether an attempt paid out. Afanasy wants to try the new machine, but he is weak at mental arithmetic, so he asked you for help.
Write a program that computes how Afanasy's capital changed over the evening. You may assume Afanasy has enough money to buy tokens for all of his attempts.
Input
The first line contains (), the number of entries in the winning table. Each of the next lines contains two values: , the combination, and , the prize for it. No combination appears in the table more than once. is exactly four digits, and .
The next line contains (), the number of times Afanasy tried his luck. Each of the following lines contains the combination that appeared on the machine.
Output
Print the change in Afanasy's capital over these games on the machine.