Implement a payment model for delivery dashers. The payment is based on the time spent on each order and the number of concurrent deliveries. Given a sequence of order activities for a dasher within a single day, calculate the total pay according to the following rules:
Payment Rules:
- Base Pay Rate: $0.3 per minute.
- Multi-Order Pay Rate: Number of ongoing deliveries multiplied by the base pay rate.
Assumptions:
- All order activities occur within the same calendar day.
- The sequence of order activities is valid:
- No duplicate orders.
- No fulfillment before pickup.
- All orders are fulfilled by the end of the day.
Input: A list of order activities, where each activity is represented as a list containing:
- Timestamp: In "HH:MM" string format.
- Action: Either
"ACCEPTED"or"FULFILLED". - Order ID: A unique string identifier for the order.
Output: The total pay for the dasher.
Example 1:
Input: activities = [["06:15", "ACCEPTED", "order-A"],["06:18", "ACCEPTED", "order-B"],["06:36", "FULFILLED", "order-A"],["06:45", "FULFILLED", "order-B"]] Output: 14.4 Explanation:
- 06:15 - 06:18: 1 order is active. Pay = 3 minutes * $0.3 = $0.9
- 06:18 - 06:36: 2 orders are active. Pay = 18 minutes * 2 * $0.3 = $10.8
- 06:36 - 06:45: 1 order is active. Pay = 9 minutes * $0.3 = $2.7
- Total Pay: $0.9 + $10.8 + $2.7 = $14.4
Example 2:
Input: activities = [["08:00", "ACCEPTED", "order-1"],["08:10", "ACCEPTED", "order-2"],["08:20", "FULFILLED", "order-1"],["08:30", "ACCEPTED", "order-3"],["08:40", "FULFILLED", "order-2"],["08:50", "FULFILLED", "order-3"]] Output: 21.0
Example 3:
Input: activities = [["00:00", "ACCEPTED", "order-X"],["23:59", "FULFILLED", "order-X"],["01:00", "ACCEPTED", "order-Y"],["02:00", "FULFILLED", "order-Y"]] Output: 449.7
