Disha and roses

Problem link:
https://www.codechef.com/FXBG2020/problems/FTB005
PROBLEM NAME-DISHA AND ROSES
AUTHOR-@dishan2925
CONTEST-CLADDING THE CODE
ORGANIZER-ROBOTICS CLUB MMMUT
DIFFICULTY-EASY
PREREQUISITES-ARRAY AND SORT FUNCTION
SOLUTION-
what to find
After analysing question it is clear that the main motive of question is to to find the number of plants in which rose flower will bloom till spring festival but the condition is that she has to plant a plant from tomorrow and she can plant only one plant a day.
Code

#include<algorithm>
#include<iostream>
#include<map>
#include<bits/stdc++.h>
using namespace std;
	// create an empty map to store frequency of array elements
 
int main()
{
	int t ;
	cin>>t;
	while(t--)
	{
		int d,n;
		cin>>d>>n;
		
		int a[n];
		int t;
		int c = 0;
		for(int i =0;i<n;i++)
		{
			cin>>a[i];
		}
		sort(a,a+n, greater<int>())	;
		for(int i =0;i<n;i++)
	    {
			if(a[i]<d)
    		{
				d=d-1;
				c++;
			}
		}
		cout<<c<<endl;
	}
	
	return 0;
}