Skip to content

Commit db68ec5

Browse files
committed
Added 1367B - Even Array.cpp
1 parent 20c52d3 commit db68ec5

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

1367B - Even Array.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ॐ नमः शिवाय
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
5+
// Code Written By: Vikash Patel
6+
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
7+
8+
int main()
9+
{
10+
int t;
11+
cin>>t;
12+
while(t--)
13+
{
14+
int n;
15+
cin>>n;
16+
int a[n];
17+
for(int i=0; i<n; i++)
18+
{
19+
cin>>a[i];
20+
}
21+
int od = 0, ev = 0;
22+
for(int i=0; i<n; i++)
23+
{
24+
if(i%2 != a[i]%2)
25+
{
26+
if(a[i]%2 == 1)
27+
od++;
28+
else
29+
ev++;
30+
}
31+
}
32+
if(od == ev)
33+
cout<<od<<endl;
34+
else
35+
cout<<-1<<endl;
36+
}
37+
}

0 commit comments

Comments
 (0)