← 返回 doordash 的题目列表Dasher Pay
类型:online_judge
Problem: Dasher Pay
DoorDash wants to calculate the total pay earned by a Dasher during a working interval.
You are given:
A working interval [S, E), measured in minutes from a common time origin.
A base hourly rate baseRate, in cents per hour.
n promotional pay intervals. Each interval is [L, R) and has an additional hourly rate extraRate, also in cents per hour.
Payment rules:
For every minute in [S, E), the Dasher earns the base hourly rate.
If a minute falls inside a promotional interval, the Dasher additionally earns that promotion's extraRate.
Promotional intervals may overlap. If multiple promotions are active at the same minute, their extra rates are added together.
A promotion may partially overlap, not overlap, or completely cover the working interval.
All intervals are half-open: [start, end).
Compute the total pay in dollars, rounded to two decimal places.
Input Format
S E
baseRate
n
L1 R1 extraRate1
L2 R2 extraRate2
...
Ln Rn extraRaten
Output Format
totalPay
totalPay is the total amount in dollars with exactly two digits after the decimal point.
Constraints
0 <= S < E <= 10^9
0 <= n <= 2 * 10^5
0 <= L_i < R_i <= 10^9
0 <= baseRate, extraRate_i <= 10^6
Input rates are in cents per hour; output is in dollars.
Example
Input:
0 120
1000
2
30 90 600
60 120 300
Output:
29.00
Explanation:
Base pay: 2 hours * $10/hour = $20
First promotion: 60 minutes * $6/hour = $6
Second promotion: 60 minutes * $3/hour = $3
Total pay: $29
Example
Input
0 60
1200
0
Output
12.00