"Count" means number of indices.

"All balloons" MUST BE burst.

Your understanding is wrong. It is something like this, as far as I understood.

x[1], x[2] are not indices of boxes. But, y[1], y[2] are indices of boxes. And each y[i] is calculated as y[i] = x[i] + ans[i-1], wherein ans[0] = 0, аnd ans[i] (i>0) — is the answer on the problem after ith bursting of the balloons.

So we have 5 boxes (namely 1 to 5, index: 1 to 5), and 3 ranges: (5,5), (2,2) and (1,3)
At the beginning, all the balloons are not yet burst.
1 1 1 1 1

Step 1: **4** ==> x[1] = 4; ans[0] = 0; So, y[1] = x[1] + ans[0] = 4 + 0 = 4

1 1 1 0 1

None of (5,5), (2,2) and (1,3) have all balloons in the boxes burst.

So, ans[1] = 0 (which is the first line of output)

Step 2: **2** ==> x[2] = 2; ans[1] = 0; So, y[2] = x[2] + ans[1] = 2 + 0 = 2

1 0 1 0 1

(2,2) now has all balloons in the boxes burst. So, "count" of indices is now 1, as there is one index such that, all balloons in boxes within the range given in that index is burst.

So, ans[2] = 1 (which is the second line of output)

Step 3: **0** ==> x[3] = 0; ans[2] = 1; So, y[3] = x[3] + ans[2] = 0 + 1 = 1

0 0 1 0 1

Still, (2,2) is the only range where all balloons in the boxes are burst. So, "count" of indices is still 1.

So, ans[3] = 1 (which is the third line of output)

Step 4: **2** ==> x[4] = 2; ans[3] = 1; So, y[4] = x[4] + ans[3] = 2 + 1 = 3

0 0 0 0 1

Now, (2,2) and (1,3) qualify. So, "count" of indices will be 2.

So, ans[4] = 2 (which is the fourth line of output)

Step 5: **3** ==> x[5] = 3; ans[4] = 2; So, y[5] = x[5] + ans[4] = 3 + 2 = 5

0 0 0 0 0

All of (5,5), (2,2) and (1,3) have all balloons in the boxes burst. So, "count" of indices will be 2.

So, ans[5] = 3 (which is the fifth line of output)