Problem 3489 · Medium

Zero Array Transformation IV

Each query offers a range and a value that may be subtracted from any chosen indices in that range. Find the smallest number of leading queries that can bring every element to exactly zero, or -1 if none can.

Open the interactive visualisation