-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathmagdaandsillypairs.cpp
More file actions
74 lines (61 loc) · 1.26 KB
/
magdaandsillypairs.cpp
File metadata and controls
74 lines (61 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <bits/stdc++.h>
//#define vi vector<int>
#define pii pair<int, int >
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = 0; i<=n i++)
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
class Algorithm {
public:
// Algorithm's function's
};
class Solution {
private:
int odd_count(long long int arr[], int n){
int sum = 0;
for(int i=0; i<n; i++){
if(arr[i]%2 == 1){
sum++;
}
}
return sum;
}
public:
// Solution approach
void Solve() {
int n;
cin>>n;
long long int a[n], b[n];
long long int total = 0;
for(int i=0; i<n; i++){
cin>>a[i];
total += a[i];
}
for(int i=0; i<n; i++){
cin>>b[i];
total += b[i];
}
int p = odd_count(a, n);
int q = odd_count(b, n);
int r = n - (min(p, q)+ min(n-p, n-q));
cout<< (total - r)/2<<endl;
}
};
signed main() {
FAST;
int testCases; cin >> testCases ; while(testCases -- ) {
Solution S;
S.Solve();
}
return 0;
}
/*
MY TEMPLATE : SANKET DAWANGE
LOGIC :
TIME COMPLEXITY :
SPACE COMPLEXITY :
DATE: 24/10/2022
*/