initial commit
This commit is contained in:
parent
d107b6d024
commit
6fb808554f
35
1367B Even Array/1367B.cpp
Normal file
35
1367B Even Array/1367B.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
using ll = long long;
|
||||
|
||||
|
||||
void solve()
|
||||
{
|
||||
int n;
|
||||
cin>>n;
|
||||
int odd_ct=0, even_ct=0;
|
||||
for(int i=0; i < n; ++i)
|
||||
{
|
||||
int x;
|
||||
cin>>x;
|
||||
if(i%2==0 && x%2!=0)
|
||||
even_ct++;
|
||||
else if(i%2!=0 && x%2==0)
|
||||
odd_ct++;
|
||||
}
|
||||
if(odd_ct!=even_ct)
|
||||
cout<<-1<<endl;
|
||||
else
|
||||
cout<<odd_ct<<endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
ios_base::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int TC = 1;
|
||||
cin >> TC;
|
||||
cin.ignore();
|
||||
while (TC--) solve();
|
||||
}
|
Loading…
Reference in New Issue
Block a user