RobloxOA #12
Rate Limit by Multiple Request Fields
Estimated MediumJudge-ready
Each request has several field dimensions, and each dimension is configured with its own fieldName, window, and limit. A request is ALLOW only if no dimension exceeds its limit; this site explicitly uses the sliding window [timestamp-window,timestamp), and only ALLOW requests are counted in each dimension's history, so requests that get REJECT do not consume quota.
Input
The first line contains d q; then d lines of fieldName window limit; then q lines of timestamp value1 ... valued. Added by this site: 1≤d≤10, 1≤q≤200000, window and limit are positive integers, values contain no spaces, and timestamps are non-decreasing.
Output
For each request, output ALLOW or REJECT, separated by spaces.
Example 1
Input:
2 6
user 10 2
device 10 3
1 u1 d1
2 u1 d1
3 u1 d1
4 u2 d1
11 u1 d1
12 u1 d1
Output:
ALLOW ALLOW REJECT ALLOW ALLOW ALLOW
Example 2
Input:
2 4
user 5 1
endpoint 3 2
1 u1 /a
2 u1 /a
2 u2 /a
4 u2 /a
Output:
ALLOW REJECT ALLOW REJECT
Example 3
Input:
1 2
user 2 1
1 u
3 u
Output:
ALLOW ALLOW
Editorial
Loading solution…