Codeforces Round 960 (Div. 2) |
---|
Finished |
You are given an array $$$a$$$ of size $$$n$$$.
There is an $$$n \times n$$$ grid. In the $$$i$$$-th row, the first $$$a_i$$$ cells are black and the other cells are white. In other words, note $$$(i,j)$$$ as the cell in the $$$i$$$-th row and $$$j$$$-th column, cells $$$(i,1), (i,2), \ldots, (i,a_i)$$$ are black, and cells $$$(i,a_i+1), \ldots, (i,n)$$$ are white.
You can do the following operations any number of times in any order:
Find the minimum number of operations to dye all cells white.
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases.
For each test case:
It's guaranteed that the sum of $$$n$$$ over all test cases will not exceed $$$2 \cdot 10^5$$$.
For each test case, output a single integer — the minimum number of operations to dye all cells white.
101042 4 4 243 2 1 030 3 030 1 333 1 043 1 0 340 2 2 261 3 4 2 0 482 2 5 2 3 4 2 4
0 3 2 1 2 2 3 2 4 6
In the first test case, you don't need to do any operation.
In the second test case, you can do:
It can be proven $$$3$$$ is the minimum number of operations.
In the third test case, you can do:
It can be proven $$$2$$$ is the minimum number of operations.
Name |
---|