#C14740. Parking System
Parking System
Parking System
You are required to implement a parking system that manages parking slots for three types of vehicles: big, medium, and small. The parking system is initially created with a given number of slots for each type. Then, there will be a sequence of car arrival events. For each event, if there is an available parking slot for the corresponding vehicle type, the car is parked and the system should output true
; otherwise, it should output false
.
The vehicle types are represented as follows:
- 1: Big vehicle
- 2: Medium vehicle
- 3: Small vehicle
Your task is to simulate this parking system by reading from standard input and printing the result for each parking attempt to standard output.
Note: If a car is parked in a slot, that slot becomes unavailable for subsequent arrivals of the same type.
inputFormat
The input is read from stdin and is structured as follows:
- The first line contains three space-separated integers: big, medium, and small, representing the initial number of parking slots available for big, medium, and small vehicles respectively.
- The second line contains an integer Q representing the number of car arrival events.
- The following Q lines each contain a single integer, which is the type of the arriving car (1 for big, 2 for medium, 3 for small).
outputFormat
For each car arrival event, output a line to stdout containing true
if the car is successfully parked; otherwise, output false
.
1 1 0
4
1
2
3
1
true
true
false
false
</p>