UVa : 12049 (Just Prune The List)



// http://uva.onlinejudge.org/external/120/12049.html
// Runtime: 0.300s
// Tag: Adhoc, map

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
using namespace std;

map <int, int> freq;

int main ()
{
	int testCase; scanf ("%d", &testCase);

	while (testCase--)
	{
		freq.clear ();
		int n, m; scanf ("%d %d", &n, &m);
		int inp;

		for (int i = 0; i < n; i++)
		{
			scanf ("%d", &inp);
			freq [inp]++;
		}

		for (int i = 0; i < m; i++)
		{
			scanf ("%d", &inp);
			freq [inp]--;
		}

		int ans = 0;
		map <int, int>::iterator it;

		for (it = freq.begin (); it != freq.end (); it++)
		{
			ans += abs ((*it).second);
		}

		printf ("%d\n", ans);
	}

	return 0;
}

One thought on “UVa : 12049 (Just Prune The List)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s