Implement employee time tracking, ranking, deferred promotions, and bonus-pay windows. Time is measured in integer ticks.
Question
Implement employee time tracking, ranking, deferred promotions, and bonus-pay windows. Time is measured in integer ticks.
```python
class Workforce:
def add_employee(self, name, position, hourly_salary) -> None: ...
def clock_in(self, employee_id, timestamp) -> None: ...
def clock_out(self, employee_id, timestamp) -> None: ...
def get_total_work_time(self, employee_id) -> int | None: ...
def top_k_workers(self, k) -> list[str]: ...
def set_promotion(self, employee_id, new_position, new_salary) -> None: ...
def calculate_pay(self, employee_id, start, end) -> int | None: ...
def set_double_pay(self, start, end) -> None: ...
```
## Requirements
- Each independent call sequence begins with a new Workforce. Add employees with sequential IDs `e1`, `e2`, and so on, even when names repeat. Mutation methods return `None`; IDs are determined by insertion order rather than returned by add_employee.
- Inputs use integer, nonnegative timestamps and rates, with rate interpreted as pay per time tick. `k` is nonnegative; return at most `k` workers, including zero-work employees. Employee IDs are compared lexicographically for ties.
- Count only completed half-open clock sessions `[in, out)`.
- Rank by completed work time descending, then employee ID ascending.
- A pending promotion activates on the employee's next successful clock-in and applies to that entire new session; it never rewrites prior sessions.
- Pay clips sessions to the requested half-open interval and uses each session's active rate.
- Double-pay windows apply a 2x multiplier only on overlap. Merge overlapping windows so no time earns 4x.
- Repeated clock-ins, unmatched clock-outs and mutations for unknown employees are no-ops. A clock-out before its open session began is a no-op that keeps the session open. A clock-in before the previous completed session ended is a no-op. Equal boundaries are permitted. Time/pay queries for unknown employees return `None`.
- A later pending promotion replaces an earlier pending promotion. Repeated clock-in does not activate it. Empty or reversed pay-query intervals return zero for a known employee; empty or reversed double-pay windows are no-ops. Double-pay windows apply to all completed sessions, including those recorded before the window was added.
The input envelope contains `calls`: a list of operation-name/positional-argument lists using exactly the eight method names above. Return one method result per call, in order; `None` is represented as JSON `null` in examples. No currency rounding or division is needed.
## Suggested implementation approach
These milestones cover the complete requirements above; they are not additional assessed stages.
1. Implement sessions and total-time ranking.
2. Add deferred promotion state and windowed pay.
3. Add merged double-pay intervals.
## Design discussion
How would you improve repeated pay queries using indexed events or prefix sums? Discuss payroll precision, retroactive corrections, audit history and concurrent clock events without changing the specified interface.The public brief is identical for people and crawlers. Account access changes tools, not the indexed description.