# Array Equal(https://www.codechef.com/SMCC2021/problems/EQUAL066)

Practice

Author: Sachin Singh
Tester: Sachin Singh
Editorialist: Sachin Singh

# DIFFICULTY:

CAKEWALK, SIMPLE, EASY.

Logical .

# PROBLEM:

You have given an array with N integers. You have to equal all elements in the given array.

RULES-

1. You can increase an element by 2.

2. You can decrease an element by 1.

3. You can perform either increase or decrease operations of any numbers of time in selected array elements.

After performing these operation if you are able to equal all array elements then print YES else print NO.

# QUICK EXPLANATION:

Here,The Output of all the testcases is YES. Because you have to given that you can decrease an any elements by 1.It’s means that all array elements must be equal after performing decrease operation by 1.

# EXPLANATION:

In simple language we can say that if we performe decrease operation in any array elements by 1.it must be same one time by other elements.

consider an example we have given an array 3 6 7 8 9. we performe 6 time decrease operation on 9 it will become 3. Similarly performe 5 time decrease by 1 operation on 8 it will become 3 and so on.At the end we will get all array elements becomes 3 3 3 3 3.

# SOLUTIONS:

Setter's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;

cin>>t;

while(t–)
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
cout<<“YES”<<endl;
}
return 0;
}

Tester's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;

cin>>t;

while(t–)
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
cout<<“YES”<<endl;
}
return 0;
}

Editorialist's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;

cin>>t;

while(t–)
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
cout<<“YES”<<endl;
}
return 0;
}