Fake Tickets
InterviewTime limit1sMemory limit128 MB
Given N genuine ticket numbers and a list of M collected ticket numbers, count how many distinct values appear more than once in the list.
- Level
Easy3 of 10
- Topics
- Array, Hash map, Implementation
- Solved
- No attempts yet
Problem
Your school threw a big party to celebrate your team's win in the prestigious, world-famous ICPC (International Collegiate Poetry Contest). Everyone at school was invited to an evening of cocktails, dinner, and a reading of your team's work to the audience. The evening was a great success — far more people than you expected showed interest in your poetry — although some of your critics said it was the food, not the words, that drew such a crowd.
Whatever the reason, the next day you learned why the school hall had felt so full: the director confided that several of the tickets guests had used were fake. The genuine tickets were numbered sequentially from to (). The director suspects some guests used the scanner and printer in the Computer Room to copy real tickets. He hands you the pack of all tickets collected at the entrance and asks you to determine how many sequence numbers were duplicated — that is, how many numbers appear on more than one ticket in the pack.
Input
The input contains data for several test cases. Each test case consists of two lines. The first line has two integers and , the number of genuine tickets and the number of guests attending the party, respectively ( and ). The second line has integers , the ticket numbers in the pack (). The end of input is indicated by a line with , which must not be processed.
Output
For each test case, print a single line containing the number of distinct sequence numbers that appear on more than one ticket in the pack.