#C8509. Cake Order Management System
Cake Order Management System
Cake Order Management System
In this problem, you are required to implement a cake order management system. The system supports the following operations:
- ADD X Y: Add a cake order with size (X) and type (Y) to the system.
- REMOVE X Y: Remove one instance of the cake order with size (X) and type (Y). If such an order does not exist, output -1.
- MAXSIZE: Output the maximum cake size among all orders. If the system is empty, output -1.
- COUNTSIZE X: Output the number of orders that have size (X). If no such orders exist, output 0.
- TYPES: Output all distinct cake types (in lexicographical order) in the system separated by a space. If there are no orders, output -1.
You have to process (Q) queries, where the first line of input contains the integer (Q) and each of the following (Q) lines contains a command as described above.
inputFormat
The first line of input contains an integer (Q), the number of queries. Each of the next (Q) lines contains a query in one of the following forms:
• ADD X Y • REMOVE X Y • MAXSIZE • COUNTSIZE X • TYPES
It is guaranteed that (X) is an integer and (Y) is a non-empty string (without spaces).
outputFormat
For each query that requires an output (REMOVE when order not found, MAXSIZE, COUNTSIZE, and TYPES), print the corresponding result on a new line. If an operation is not possible (for example, removing a non-existent order or querying an empty system), print -1 (or 0 for COUNTSIZE as specified).## sample
5
ADD 10 chocolate
ADD 15 vanilla
MAXSIZE
COUNTSIZE 10
TYPES
15
1
chocolate vanilla
</p>