#K61657. Design a Parking System
Design a Parking System
Design a Parking System
Your task is to implement a parking system that handles three different types of parking spaces: big, medium, and small. When the system is initialized, it is given the number of available slots for each type. Then, the system processes a series of parking queries. For each query, a car of a particular type (1 for big, 2 for medium, 3 for small) attempts to park.
If a parking slot is available for the corresponding car type, the car is parked and the system returns \(\text{true}\); otherwise, it returns \(\text{false}\). All interaction is done via standard input (stdin) and standard output (stdout).
Note: Let \(big\), \(medium\), and \(small\) denote the number of parking spaces available for each car type respectively.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains three space-separated integers: \(big\), \(medium\), and \(small\), representing the number of available parking spots for each category.
- The second line contains an integer \(Q\), representing the number of parking queries.
- Each of the following \(Q\) lines contains an integer, which is one of {1, 2, 3}, indicating a parking request for a car of that type.
outputFormat
Output exactly \(Q\) lines to standard output (stdout). For each parking query, print true
if the car successfully parks, or false
if it cannot be parked.
1 1 0
4
1
2
3
1
true
true
false
false
</p>