Advertisement
Eather

uva 12049 for Alim

Oct 30th, 2012
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include<cstdio>
  2. #include<vector>
  3. #include<map>
  4. #include<algorithm>
  5. using namespace std;
  6. vector<long long>a;
  7. map<long long,long long>m;
  8. int main()
  9. {
  10.     int test;
  11.     int p,q;
  12.     scanf("%d",&test);
  13.     while(test--)
  14.     {
  15.         long long num;
  16.         scanf("%d %d",&p,&q);
  17.         for(int i=0;i<p;i++)
  18.         {
  19.             scanf("%lld",&num);
  20.             m[num]++;
  21.             a.push_back(num);
  22.         }
  23.         for(int i=0;i<q;i++)
  24.         {
  25.             scanf("%lld",&num);
  26.             m[num]--;
  27.             a.push_back(num);
  28.         }
  29.         sort(a.begin(),a.end());
  30.  
  31.         a.erase(unique(a.begin(),a.end()),a.end());
  32.         long long res=0;
  33.         for(long long i=0;i<a.size();i++){if(m[a[i]]!=0)res+=abs(m[a[i]]);}
  34.         printf("%lld\n",res);
  35.         a.clear();m.clear();
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement