#C14036. Vehicle Management System
Vehicle Management System
Vehicle Management System
You are required to implement a vehicle management system which handles an initial list of vehicles and processes several queries. Each vehicle is described by its license number, type, and capacity. You must support the following queries:
QUERY <vehicle_type>
: Print, in one line, the license numbers (separated by a single space) of all vehicles matching the given type.MAX
: Print the license number of the vehicle with the highest capacity. In case of a tie, choose the first one in the list.ADD <license_number> <vehicle_type> <capacity>
: Add a new vehicle with the given details to the list and print its license number.
The input and output are handled through standard input and output respectively.
inputFormat
The first line contains an integer N representing the number of vehicles. The following N lines each contain vehicle details in the format: license,vehicle_type,capacity
(comma-separated, without extra spaces). The next line contains an integer Q representing the number of queries. Each of the following Q lines contains a query in one of the following formats:
QUERY <vehicle_type>
MAX
ADD <license_number> <vehicle_type> <capacity>
outputFormat
For each query, output the result on a separate line. For a QUERY
command, print the license numbers of vehicles of that type separated by a single space (print an empty line if none match). For the MAX
command, print the license number of the vehicle with the highest capacity. For the ADD
command, print the license number of the newly added vehicle.## sample
4
AB1234,car,4
XY5678,truck,10
GH4321,bike,2
JK0987,car,5
3
QUERY car
MAX
ADD LM3456 bike 3
AB1234 JK0987
XY5678
LM3456
</p>