Prototype: PriorityQueue.add(name,priority) returns increasing IDs starting 1; pop removes highest priority then smallest ID as TaskItem, or null. Duplicate names/negative priorities are valid.

Final: TaskScheduler.addTask uses the same IDs/order. addWorker requires positive capacity and preserves existing capacity on duplicate. dispatch(ts,worker,lease) requires positive lease before time validation, expires leases, enforces worker quota, and returns Task or null. Successful global lease tokens start 1, failures consume none. complete(ts,id,token) succeeds only for the current unexpired running lease, then clears metadata and marks done. getTask/active also expire first; active is ID sorted. All timed methods require nonnegative nondecreasing ts; valid failures advance time, invalid requests do not. Expiry is expiresAt <= ts; pending/done metadata is null.

The complete public API is in Exercise.java. All domain classes are public static nested classes of Exercise; construct them as new Exercise.ClassName(...). Do not implement a solution in the test runner. Each instance owns independent state. Unless explicitly allowed, null inputs are outside the domain. Failed operations leave state unchanged; validation happens before mutation.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.

Java runs on this device with CheerpJ 4.3.