Token bucket with refill
Your task
Simulate a token-bucket rate limiter. The bucket starts full with capacity tokens and refills at refill_rate tokens per time unit, never exceeding capacity. Given a chronologically ordered list of [timestamp, cost] requests, each request first refills the bucket based on elapsed time since the previous request, then is allowed (consuming cost tokens) only if at least cost tokens are available. Return a list of booleans for the requests. Timestamps are non-decreasing.
Examples
token_bucket(capacity: int, refill_rate: int, requests: list[list]) -> list[bool]Example 1
Input
token_bucket(2, 1, [[0, 1], [0, 1], [0, 1]])Output
[True, True, False]