cswork / OA打开练习工作台

CircleOA #2

User Quota Scheduling with Expiring Assignments

估计中等评测数据准备中,可先阅读题面

考点(AI 标注)迭代器设计前缀和区间

Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem. Problem: User Quota Scheduling with Expiring Assignments (Level 3) Implement a user/task scheduling system. Requirements Create user: each user has a quota meaning the maximum number of concurrent assignments allowed for that user. Assign a task: assign to a user a time interval [startTime, endTime) with a taskId. Rules Each assignment is active on the half-open interval [startTime, endTime). Once endTime is reached, the assignment expires and no longer counts toward the user’s concurrent quota. Example: existing assignment [4,10) no longer counts for any t ≥ 10. If adding a new assignment would make the number of concurrent active assignments exceed quota at any time, the assignment must be rejected. Output For each assignment attempt, output whether it succeeds (e.g., true/false or OK/FAIL per spec). Constraints Potentially large, but OA tests may be small; a straightforward approach may pass. Test ideas quota=1: add [4,10) ok; add [10,12) ok. quota=1: add [4,10) ok; add [9,12) reject. quota=2: adding a third overlapping interval should reject. Edge: zero-length intervals (per spec). Multiple users are independent. Function Description Complete solveUserQuotaScheduling. It has one parameter, String input, containing the full stdin payload. Return the stdout payload as an array of lines, without trailing newline characters.

Constraints

Use the limits and requirements stated in the prompt.

Example 1

Input:

input = "CREATE_USER u1 1\nASSIGN u1 1 4 10\nASSIGN u1 2 10 12"

Output:

["OK", "OK"]

Explanation: The returned string must match the expected standard output for the sample input.