Simulate a waiter handling arrivals and pickups with a busy period and bounded tray capacity.
You are modeling a simple waiter in a restaurant. The waiter starts with a tray that can hold at most `capacity` dishes. The waiter serves dishes one at a time, but after each pickup they need a short break (a busy period) of exactly 2 time units. During this break, new dishes may arrive, but the waiter does not process any events until the break ends. Events that occur during a busy period are queued and processed after the busy period ends, in order of their original event time (ties broken by the order given in the input list). If an event occurs exactly when the busy period ends, it is processed normally (not delayed).
Implement the function `process_dishes(capacity: int, event_list: list) -> list`:
- `capacity`: integer, maximum number of dishes the tray can hold.
- `event_list`: list of events, each event is a tuple `(time, action, value)`, where:
- `time` is a non-negative integer, and events are sorted in non-decreasing time order.
- `action` is either `'arrive'` or `'pickup'`.
- `value` is a positive integer.
The waiter starts idle at time 0 with an empty tray.
Processing rules:
1. Process events in chronological order (smallest time first). If multiple events have the same time, process them in the order they appear in `event_list`.
2. When an event is processed at time `t`:
- If `t` is before the end of the current busy period (if any), the event is postponed: it will be processed later, when the waiter becomes free, at the earliest time not earlier than its original time.
- If the waiter is free (i.e., `t` is at or after the busy period end), the event is handled immediately.
3. `'arrive'`: add `value` dishes to the tray, but the tray cannot exceed `capacity`. Any amount that would exceed capacity is discarded.
4. `'pickup'`: the number of dishes picked up is `min(value, current_tray)`. The tray is reduced by that amount. After a pickup, the waiter becomes busy for exactly 2 time units starting from the actual processing time of that pickup.
Your function must return a list of integers: the number of dishes picked up for each pickup event, in the order the pickup events are actually processed (including those that were postponed). If a pickup is processed when the tray is empty, the amount is 0.
You need to implement exactly:
```python
def process_dishes(capacity: int, event_list: list) -> list:
pass
```
Note: You do not need to simulate real threading; just deterministically process the events as described.
Constraints
- 1 <= capacity <= 10^4
- 0 <= len(event_list) <= 10^4
- Each event time is a non-negative integer; the list is sorted in non-decreasing time order.
- For 'arrive' events, value >= 1; for 'pickup' events, value >= 1.
- Total dishes arriving can be large (up to 10^9), but the tray capacity bounds what is kept.
- Complexity: O(n log n) time and O(n) space (besides the output).
Example
>>> process_dishes(3, [(1, 'arrive', 5), (2, 'pickup', 2), (3, 'pickup', 4)])
[2, 1]
>>> process_dishes(2, [(0, 'arrive', 1), (0, 'pickup', 2), (1, 'pickup', 1), (3, 'arrive', 2)])
[1, 0]
10 points
~15 min