# PROBLEM LINK:

Practice

Div-2 Contest

Div-1 Contest

In case the contest did not have two separate pages for Div-1 and Div-2, you can delete one of these above lines.

* Author:* Abhishek Yadav

*Abhishek Yadav*

**Tester:***Abhishek Yadav*

**Editorialist:**# DIFFICULTY:

EASY

# PREREQUISITES:

Basic Maths, Even numbers, Odd numbers.

# PROBLEM:

Anuj and Anurag are Playing a Game of arrays in which they are given an array of size N. Let’s consider the indexing of array starts from 1. And they have to place the even array values at even indexes and odd array values at odd indexes.

When the array size (i.e N) was small they both did the task easily but now the array size is too large and they are unable to do it.

Now it’s your job to make a program which will do the given task. You have to just print “YES” . If it is possible to place every elements in its proper indexes. (i.e Print “YES” if they can place the even elements at even indexes and odd at odd indexes. Else print “NO”.)

# QUICK EXPLANATION:

In this problem you have to just find that wheather we can rearrange the elements in proper places or not.

i.e we just need to check it we are not said to do it ok.

# EXPLANATION:

you have to just calculate the total number of odd and even places i.e just calculate the total number of odd indexes and total number of even indexes and nextly we have to cound the total number of odd elements and total number of even elements. if the total number of odd indexes is equal to total number of odd elements and same for even numbers also.

so just print “YES” without collens

else print “NO”.

# SOLUTIONS:

## Setter's Solution

#include<bits/stdc++.h>

using namespace std;

int main()

{

int t;

cin>>t;

while(t–)

{

int n,flag=0,flag1=0,even=0,odd=0;

cin>>n;

int c=n/2;

flag=c;

if(n%2==0)

{

flag1=c;

}

else

{

flag1=c+1;

}

int a[n];

for(int i=0;i<n;i++)

{

cin>>a[i];

if(a[i]%2==0)

{

even++;

}

else

{

odd++;

}

}

if(even==flag && odd==flag1)

{

cout<<“YES”<<endl;

}

else

{

cout<<“NO”<<endl;

}

```
}
```

}

## Tester's Solution

#include<bits/stdc++.h>

using namespace std;

int main()

{

int t;

cin>>t;

while(t–)

{

int n,flag=0,flag1=0,even=0,odd=0;

cin>>n;

int c=n/2;

flag=c;

if(n%2==0)

{

flag1=c;

}

else

{

flag1=c+1;

}

int a[n];

for(int i=0;i<n;i++)

{

cin>>a[i];

if(a[i]%2==0)

{

even++;

}

else

{

odd++;

}

}

if(even==flag && odd==flag1)

{

cout<<“YES”<<endl;

}

else

{

cout<<“NO”<<endl;

}

```
}
```

}

## Editorialist's Solution

#include<bits/stdc++.h>

using namespace std;

int main()

{

int t;

cin>>t;

while(t–)

{

int n,flag=0,flag1=0,even=0,odd=0;

cin>>n;

int c=n/2;

flag=c;

if(n%2==0)

{

flag1=c;

}

else

{

flag1=c+1;

}

int a[n];

for(int i=0;i<n;i++)

{

cin>>a[i];

if(a[i]%2==0)

{

even++;

}

else

{

odd++;

}

}

if(even==flag && odd==flag1)

{

cout<<“YES”<<endl;

}

else

{

cout<<“NO”<<endl;

}

```
}
```

}