Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unordered_map>
- #include <math.h>
- using namespace std;
- int main() {
- int numOfStudents, numOfStudents2;
- std::unordered_map<int,int> firstGroup;
- std::unordered_map<int,int> secondGroup;
- std::cin >> numOfStudents;
- numOfStudents2 = numOfStudents;
- while(numOfStudents--)
- {
- int a;
- std::cin >> a;
- ++firstGroup[a];
- }
- while(numOfStudents2--)
- {
- int a;
- std::cin >> a;
- ++secondGroup[a];
- }
- int diff = 0;
- for (int i = 1; i <= 5; ++i)
- {
- diff += std::abs(firstGroup[i] - secondGroup[i]);
- }
- if (diff % 4 != 0)
- std::cout << -1 << std::endl;
- else
- std::cout << diff / 4 << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement