Not able to solve the que. given in the link


#include
#include
using namespace std;
int main()
{
int t;
cin>>t;
while(t–){

int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];

// cout<<nop(arr)
sort(arr,arr+n);
int nof=0;
int i=n-1;
while(1)
{

    if(i<=0)
        break;
    while(arr[i]-5>=arr[0]){
        arr[i]-=5;
        nof++;
        }
         while(arr[i]-2>=arr[0]){
        arr[i]-=2;
         nof++;}
          while(arr[i]-1>=arr[0]){
        arr[i]-=1;
         nof++;}

    if(arr[i]==arr[0])
    {
        i--;
    }

}

cout<<nof<<endl;
}

}

my approach-^^^^

HI @LP19DPPM0036 you can see the editorial of the problem if you are not able to figure it out :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.