Internet Cafe Seat Requests
InterviewTime limit2sMemory limit128 MB
Given a sequence of seat requests for 100 computers, count how many requests are rejected because the requested seat is already taken.
- Level
Easy2 of 10
- Topics
- Simulation, Array, Implementation
- Solved
- No attempts yet
Problem
Sejun works part-time at an internet cafe. The cafe has computers numbered from 1 to 100.
Each arriving customer states the number of the computer they want to use. If that seat is empty, the customer sits there and uses the computer. If someone is already sitting there, the customer is rejected.
Initially, every seat is empty, and a seated customer never leaves. Given the customers' requested seats in arrival order, determine how many customers are rejected.
Input
The first line contains the number of customers, N. N is at most 100.
The second line contains the seat number requested by each customer, in arrival order.
Output
Print the number of rejected customers on the first line.