-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeForces-779A.cpp
More file actions
46 lines (38 loc) · 783 Bytes
/
CodeForces-779A.cpp
File metadata and controls
46 lines (38 loc) · 783 Bytes
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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
map<int, int> A, B;
int n;
cin >> n;
for(int i = 1; i <= 5; i++){
A[i] = 0;
B[i] = 0;
}
int temp;
for(int i = 0; i < n; i++){
cin >> temp;
A[temp]++;
}
for(int i = 0; i < n; i++){
cin >> temp;
B[temp]++;
}
int mudancas = 0;
for(int i = 1; i <= 5; i++){
if((A[i] + B[i])%2 == 0){
if(A[i] == B[i]) {
continue;
}
else{
mudancas += abs(A[i] - B[i])/2;
}
}else{
cout << -1 << endl;
return 0;
}
}
cout << mudancas/2 << endl;
return 0;
}