/*一定度清楚题意,是小领导要求a,b两个小组具有相同多的value的学生*/#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int a[55], b[55];int main(){ int n, num; while(scanf("%d", &n) != EOF){ memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); for(int i = 0; i < n; i++){ scanf("%d", &num); a[num]++;//这种题独特的技术方法 第二次碰到 } for(int j = 0; j < n; j++){ scanf("%d", &num); b[num]++; } int ans = 0; for(int i = 1; i <= 5; i++){ if((a[i] + b[i]) % 2) {cout << "-1" << endl;return 0;} if((a[i] + b[i]) == 0) continue; if(((a[i] + b[i]) != 0) && a[i] != b[i]){ ans += abs(a[i] - (a[i] + b[i])/2); } } cout << ans/2 << endl;//因为 共加了两次 } return 0;}
新闻热点
疑难解答