Educational Codeforces Round 46 (Rated for Div. 2) A Codehorses T-shirts

A. Codehorses T-shirts
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Codehorses has just hosted the second Codehorses Cup. This year, the same as the previous one, organizers are giving T-shirts for the winners.

The valid sizes of T-shirts are either "M" or from 00 to 33 "X" followed by "S" or "L". For example, sizes "M""XXS""L""XXXL" are valid and "XM""Z""XXXXL" are not.

There are nn winners to the cup for both the previous year and the current year. Ksenia has a list with the T-shirt sizes printed for the last year cup and is yet to send the new list to the printing office.

Organizers want to distribute the prizes as soon as possible, so now Ksenia is required not to write the whole list from the scratch but just make some changes to the list of the previous year. In one second she can choose arbitrary position in any word and replace its character with some uppercase Latin letter. Ksenia can't remove or add letters in any of the words.

What is the minimal number of seconds Ksenia is required to spend to change the last year list to the current one?

The lists are unordered. That means, two lists are considered equal if and only if the number of occurrences of any string is the same in both lists.

Input

The first line contains one integer nn (1n1001≤n≤100) — the number of T-shirts.

The ii-th of the next nn lines contains aiai — the size of the ii-th T-shirt of the list for the previous year.

The ii-th of the next nn lines contains bibi — the size of the ii-th T-shirt of the list for the current year.

It is guaranteed that all the sizes in the input are valid. It is also guaranteed that Ksenia can produce list bb from the list aa.

Output

Print the minimal number of seconds Ksenia is required to spend to change the last year list to the current one. If the lists are already equal, print 0.

Examples
input
Copy
3
XS
XS
M
XL
S
XS
output
Copy
2
input
Copy
2
XXXL
XXL
XXL
XXXS
output
Copy
1
input
Copy
2
M
XS
XS
M
output
Copy
0
Note

In the first example Ksenia can replace "M" with "S" and "S" in one of the occurrences of "XS" with "L".

In the second example Ksenia should replace "L" in "XXXL" with "S".

In the third example lists are equal.

#include<bits/stdc++.h>

 using namespace std;

 int a[100] , b[100];

 int main()
 {
 	int n ;
 	cin >> n;
 	string s;
 	for(int i = 1; i <= n ; i ++)
	{
		cin >> s;
		if( s == "S" )
		{
			a[1] ++;
		}
		else if(  s == "XS" )
			a[2] ++;
		else if( s == "XXS" )
			a[3] ++;
		else if( s == "XXXS" )
			a[4] ++;
		else if( s == "M" )
			a[5] ++;
		else if( s == "L" )
			a[6] ++;
		else if( s == "XL" )
			a[7] ++;
		else if( s == "XXL" )
			a[8] ++;
		else if( s == "XXXL" )
			a[9] ++;
	}
	for(int i = 1; i <= n ; i ++ )
	{
		cin >> s;
		if( s == "S" )
		{
			b[1] ++;
		}
		else if(  s == "XS" )
			b[2] ++;
		else if( s == "XXS" )
			b[3] ++;
		else if( s == "XXXS" )
			b[4] ++;
		else if( s == "M" )
			b[5] ++;
		else if( s == "L" )
			b[6] ++;
		else if( s == "XL" )
			b[7] ++;
		else if( s == "XXL" )
			b[8] ++;
		else if( s == "XXXL" )
			b[9] ++;
	}
	int flag = 1;
	for(int i = 1 ;i <= 9 ;i ++)
	{
		if(a[i] != b[i])
		{
			flag = 0 ;
			break;
		}
	}
	int sum = 0;
	if(flag)
	{
		cout << "0";
		return 0;
	}
	else
	{
		for(int i = 1; i <= 9 ; i ++)
		{
			a[i] -= b[i];
			if(a[i] > 0)
				sum += a[i];
			//cout << a[i] << " ";
		}
		//cout << endl;
	}
	cout << sum ;
 	return 0;
 }

猜你喜欢

转载自blog.csdn.net/ant_e_zz/article/details/80837694