← 返回 optiver 的题目列表Order Book Matching Simulation
类型:online_judge
Implement an order book matching simulator. The simulator takes in queues of buy and sell orders and matches them based on price-time priority, outputting the state of the book after each completed trade.
Input
buy_orders: A list of pending buy orders, each order is [timestamp, price, quantity].
sell_orders: A list of pending sell orders, each order is [timestamp, price, quantity].
Output
Return the state of the order book after each completed order, formatted as a list including unfinished and finished orders.
Test Example
Example 1
Input: buy_orders = [[1, 100, 5], [2, 110, 5]], sell_orders = [[3, 90, 5]]
Output: [[], [[3, 90, 5]]]
Constraints
The length of buy_orders and sell_orders does not exceed 100.
Prices and quantities are less than 1000.
Example
Input
2
1 100 5
2 110 5
1
3 90 5