Limit Order Book Matching Engine: Price-Time Priority
Problem Statement
You are implementing the core matching engine for an electronic securities trading exchange.
In **Price-Time Priority (FIFO)** matching:
- **Sell orders** (Asks) with lower price have priority over asks with higher price.
- When prices are identical, orders placed earlier in time are executed first.
Given a list of existing limit sell orders (asks) and an incoming market buy order for `requestedQuantity` shares, return the total dollar expenditure required to fill the buy order, and how many shares remain unfilled (if any).
### Input Format
- First line contains two integers: `n` (number of asks) and `requestedQuantity`.
- The next `n` lines each contain three integers: `price quantity timestamp`.
### Output Format
- Print two space-separated integers: `totalCost remainingUnfilled`.
### Constraints
- `1 <= n <= 10^5`
- `1 <= requestedQuantity <= 10^9`
- `1 <= price, quantity, timestamp <= 10^6`
Sample Cases
Example 1Sample Case
Input: 3 12
100 10 1
99 5 3
99 10 2
Output: 1188 0
Example 2Sample Case
Input: 1 10
50 5 1
Output: 250 5
Example 3Sample Case
Input: 2 15
100 10 1
100 10 2
Output: 1500 0
Constraints
Runtime Limit: 2000 ms per test batch
Memory Limit: 256 MB
Standard I/O stream reading
Official submissions are evaluated against hidden test cases on the server to verify time & memory complexity.