Approach hintTry it first, then revealHide
Use a segment tree with lazy range addition and range minimum. A circular segment with l > r splits into [l, n-1] and [0, r]; take care when parsing lines that hold either two or three numbers.
Use a segment tree with lazy range addition and range minimum. A circular segment with l > r splits into [l, n-1] and [0, r]; take care when parsing lines that hold either two or three numbers.