Worker Management with Promotions and Double-Paid Time
Problem statement
Continue the worker management system from Part 3. Existing worker, session, promotion, ranking, and salary operations keep their behavior.
Double-Paid Time
["SET_DOUBLE_PAID", start_timestamp, end_timestamp]: register the half-open interval[start_timestamp, end_timestamp)as double-paid time and return an empty string.- Double-paid intervals apply globally to every worker.
- Merge overlapping intervals. Time covered by multiple registered intervals is still paid at most twice, never three or more times.
CALC_SALARYfirst pays normal compensation for completed-session time, then adds one extra copy of compensation for the portion inside double-paid intervals.
Function
workerManagementLevel4(operations: String[][]) → String[]Examples
Example 1
operations = [["ADD_WORKER","Alice","Engineer","100"],["REGISTER","Alice","10"],["REGISTER","Alice","30"],["SET_DOUBLE_PAID","15","25"],["CALC_SALARY","Alice","0","40"],["SET_DOUBLE_PAID","20","35"],["CALC_SALARY","Alice","0","40"]]return = ["true","registered","registered","","3000","","3500"]Alice's completed session pays 20*100 = 2000 normally. The first double-paid interval overlaps it for 10 units, producing 3000. After merging [15,25) with [20,35), the session has 15 double-paid units, producing 3500.
Constraints
1 <= operations.length <= 5000.- Worker identifiers and positions are nonempty strings without the separator used by the operation matrix.
- Timestamps are nonnegative integers and office-entry/exit timestamps are strictly increasing globally.
- Compensation, timestamps, completed time, and salary fit in signed 64-bit integers.
- Every double-paid interval satisfies
start < end.