Codeforces Round 990 (Div. 2) |
---|
Finished |
Alyona assembles an unusual square Jigsaw Puzzle. She does so in $$$n$$$ days in the following manner:
For example, she places the first $$$14$$$ pieces in the following order:
Alyona is happy if at the end of the day the assembled part of the puzzle does not have any started but unfinished layers. Given the number of pieces she assembles on each day, find the number of days Alyona is happy on.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 500$$$). The description of the test cases follows.
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$), the number of days.
The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 100$$$, $$$a_1 = 1$$$), where $$$a_i$$$ is the number of pieces Alyona assembles on the $$$i$$$-th day.
It is guaranteed in each test case that at the end of the $$$n$$$ days, there are no unfinished layers.
For each test case, print a single integer: the number of days when Alyona is happy.
51121 851 3 2 1 271 2 1 10 2 7 2141 10 10 100 1 1 10 1 10 2 10 2 10 1
1 2 2 2 3
In the first test case, in the only day Alyona finishes the only layer.
In the second test case, on the first day, Alyona finishes the first layer, and on the second day, she finishes the second layer.
In the third test case, she finishes the second layer in a few days.
In the fourth test case, she finishes the second layer and immediately starts the next one on the same day, therefore, she is not happy on that day. She is only happy on the first and last days.
In the fifth test case, Alyona is happy on the first, fourth, and last days.
Name |
---|