Circular Minimum Console
Preview mode. Log in to edit, run, submit, and save progress.
Circular Minimum Console
A monitoring console stores values around a circular dashboard. Operations either add a number to every position on a circular interval, or ask for the minimum value on a circular interval. An interval l to r moves clockwise from l to r; if l is greater than r, the interval wraps around the end of the dashboard. Input Format: The first line contains t. Each case contains n, then n values, then q operations. Operation 0 l r delta adds delta to the interval. Operation 1 l r asks for the current minimum on the interval. Positions are 1-indexed. Output Format: Print one line for every query operation.
Examples
1 4 5 2 9 1 5 1 1 4 0 3 1 4 1 4 2 0 2 3 -3 1 1 3
1
Explanation: The first query reads the whole dashboard. Later updates include a wrapped interval, so both ends of the array can change together.
Approach hint
A wrapped interval can be split into two normal intervals.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.