← 返回 doordash 的题目列表Driver Pay From Order Status Timeline (overlapping orders, minute-based)
类型:online_judge
Problem: Compute Driver Pay From Order Status Timeline (minute-based, overlapping orders)
You are given a set of order status change events describing when each order was accepted and when it was delivered. Driver pay is computed per minute:
There is a fixed rate (money per minute).
If during a given minute the driver is simultaneously handling k orders, pay for that minute is k * rate.
Compute the total pay implied by the events.
In the real interview, I/O and data structures may be negotiated. Below is a concrete, implementable version.
Input (suggested)
Line 1: two integers n rate
Next n lines: order_id timestamp status
status is one of: ACCEPTED, DELIVERED
Rules
Each order appears exactly once with ACCEPTED and once with DELIVERED, and accept_time < deliver_time.
Each order contributes an active interval [accept_time, deliver_time).
If events are unsorted, sort by timestamp before processing.
Output
One integer: total pay.
Constraints (suggested)
1 <= n <= 2e5, timestamp up to 1e9.
Example
Input
4 5
A 0 ACCEPTED
A 10 DELIVERED
B 3 ACCEPTED
B 8 DELIVERED
Output
75