Counting the no of elements in a data structure, printing the count for each position and decrement the iteration using recursion : Various signal towers are present in a city.Towers are aligned in a straight horizontal line(from left to right) and each tower transmits a signal in the right to left direction.Tower A shall block the signal of Tower B if Tower A is present to the left of Tower B and Tower A is taller than Tower B. So,the range of a signal of a given tower can be defined as :

{(the number of contiguous towers just to the left of the given tower whose height is less than or equal to the height of the given tower) + 1}.

    #include <iostream>
    #include <vector>
    using namespace std;
    vector<int> res;
    void recursion(int a[],int x)
    {
	if (x >= 0)
	{// Taking the last element of the array as the max element
		int max = a[x], count = 0;
		for (int i = x; i >= 0; i--)
		{//Comparing the max with all the elements in the array
			if (max >= a[i])
			{
				count++;
			}
			else
			{
				break;
			}
		}
		//Pushing the count of the current element in the vector.
		res.push_back(count);
		x = x - 1;
		recursion(a, x);
	}
    }
        int main() {
	int TestCase, n;
	cin >> TestCase;
	for (int l = 0; l < TestCase; l++)
	{
		cin >> n;
		int * arr = new int[n];
		//Getting the elements
		for (int j = 0; j < n; j++)
		{
			cin >> arr[j];
		}
		recursion(arr, n-1);
		//Iterating through the vector in reverse manner and printing 
                //the result.
		for (auto it = res.rbegin(); it != res.rend(); ++it)
		{
			cout << *it << " ";
		}
		delete[] arr;
	}
	return 0;
    }


    First line contains an integer T specifying the number of test cases.

    Second line contains an integer n specifying the number of towers.

    Third line contains n space separated integers(H[i]) denoting the height 
    of each tower.
    
    Print the range of each tower (separated by a space).
    Sample Input :
    1
    7
    100 80 60 70 60 75 85
    
    Sample Output :
    1 1 1 2 1 4 6

    My solution is correct but the time complexity is the issue. Is there any 
    way to reduce time complexity?