Entry Records
InterviewTime limit1sMemory limit1024 MB
Given today's ordered entry and exit records, find the fewest records that must be missing so each person's enter and leave events alternate correctly.
- Level
Easy3 of 10
- Topics
- Hash map, Implementation
- Solved
- No attempts yet
Problem
A military police officer at a guard post finished the day shift and went through today's entry records for a security check. He realized that some of today's entry records are missing.
Today's entry records total , and the records are always written in the order in which people entered or left.
The -th entry record is written as two integers and . is the number of the person entering or leaving. If is , the person entered the base. If is , the person left the base. Before the first record and after the last record, nobody was inside the base.
Using today's entry records, find the minimum number of missing entry records over the whole day.
Input
The first line contains the number of entry records . ()
From the second line through line , the -th entry record is given as the integers and , separated by a space. (, )
Output
Print the minimum number of entry records that were missing during the day.