You are given an event log for a system of “pods.” Each event is a pair [status, value]:
-
status == 1
: Add a new pod with
initial load
=
value
.
-
status == 2
: Increase the load of
every existing pod
by
value
(a global increment).
-
status == 3
: Remove the pod with the
smallest current load
and
output/record
that pod’s current load. (For
status == 3
, the
value
field can be ignored.)
Return a list of the loads produced by every status == 3 operation, in order.
Example
Input:
logs = [[1, 5], [1, 2], [2, 3], [3, 0], [3, 0]]
Process:
-
add pod(5)
-
add pod(2)
-
+3 to all ⇒ loads become (8, 5)
-
pop min ⇒ output 5
-
pop min ⇒ output 8
Output: [5, 8]
Notes / assumptions
-
It is guaranteed that a
status == 3
event will not occur when there are no pods.
-
Use 64-bit integers if needed.
-
Aim for an efficient solution (e.g., better than O(n) per global increment).