Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* BISMILLAHIR-RAHMANIR-RAHIM
- ____________________________________
- | |
- | SHANTO_SUST_SWE-19_029 |
- |____________________________________|
- */
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include <stdlib.h>
- #include <time.h>
- #define debug 1
- int main()
- {
- int t;
- scanf("%d", &t);
- int n;
- int i, even, odd, count;
- while(t--){
- scanf("%d", &n);
- int ara[n];
- even = 0, odd = 0, count = 0;
- for(i = 0; i < n; i++){
- scanf("%d", &ara[i]);
- if(ara[i] % 2 == 0) even++;
- else odd++;
- }
- if(n % 2 == 0){
- if(even == odd){
- for(i = 0; i < n; i++){
- if(i % 2 != ara[i] % 2) count++;
- }
- printf("%d\n", count / 2);
- }
- else printf("-1\n");
- }
- else{
- if(even == odd + 1){
- for(i = 0; i < n; i++){
- if(i % 2 != ara[i] % 2) count++;
- }
- printf("%d\n", count / 2);
- }
- else printf("-1\n");
- }
- }
- return 0;
- }
- //ALHAMDULILLAH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement