题目:

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 3“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
3
XS
XS
M
XL
S
XS
Output
2
Input
2
XXXL
XXL
XXL
XXXS
Output
1
Input
2
M
XS
XS
M
Output
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 <iostream>
#include <map>
using namespace std;
const int N = 105;
string a[N],b[N];
map <string,int> A,B;
int main()
{
    int n;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>a[i];
    }
    for (int i=0;i<n;i++) {
        cin>>b[i];
    }
    for (int i;i<n;i++) {
        A[a[i]]++;
        B[b[i]]++;
    }
    map <string,int>::iterator it;
    int ans=n;
    for (it=A.begin();it!=A.end();it++) {
        ans-=min(it->second,B[it->first]);
    }
    cout<<ans<<endl;
    return 0; 
}

这个头文件的话,经我测试,实际上只需要这两个头文件即可。string的头文件不需要加入进来就可以在本地和远程服务器上编译通过且不报错,

也可以直接就写那个包含所有的头文件,也很方便。

首先声明string类的a,b数组,然后for循环输入,每次输入一个字符串,写在a【i】里面,一个string就可以装一个字符串,不要把它当成字符串数组。

关于如何计算出来最后的结果实际上就是,假定每一个尺码都要修改,然后在a的second里面寻找一个尺码的数目,然后在b里面寻找这个尺码的数目。

取它俩的最小值,因为最后是减去这个值所以要取最小值。如果有相通的,第二个数就会有值,总共需要修改的减去不需要变更的,就是要修改的值了。

这里面首先在map里面是升序排列的,第二map里面是映射的关系。

循环一遍就算出了总值。基本上就这么多了。

版权声明:本文为xyqxyq原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/xyqxyq/p/9321342.html