当前位置: 首页 > 工具软件 > t-shirts > 使用案例 >

Codehorses T-shirts

郎志
2023-12-01

题目:

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 (1≤n≤1001≤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.

题目大意:

这里有M,S,XS,XXS,XXXS,L,XL,XXL,XXL这几种号码的T恤衫。先输入一个整数n,首先输入的n行表示以前n件T恤衫的号码,第二次输入的n行表示现在需要的T恤衫号码。题目要求:从以前拥有的T恤衫号码变为现在需要的T恤衫,问最少需要改动几次才能达到要求。

这里可以用两层for循环来实现,第一层for循环表示现在所需要的T恤衫号码,第二层for循环表示原来所拥有的T恤衫号码,用现在的与原来的做对比。i表示现在,j表示原来,flag做标记(对于每一个i值,flag开始时都标记为1,只要j中有与i处相同的字符串就把flag更新为0,这样就不会将i统计为需要改变的字符串)对于每一个i都与所有的j做对比,只要两个位置的字符相等,就把flag标记为0,同时,再把j上对应位置的字符为0,这样,下一个i再比较到这个位置flag时,不会出现二次比较的情况。

代码如下:

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<iostream>
#include<queue>
using namespace std;
int main()
{
    int n,sum,flag;
    string pr[101],cr[101];
   
        cin>>n;
        sum=0;
        for(int i=0;i<n;i++)
           cin>>pr[i];//string定义的,只能用cin
        for(int i=0;i<n;i++)
            cin>>cr[i];
        for(int i=0;i<n;i++)//i代表现在
        {
            flag=1;
            for(int j=0;j<n;j++)//j代表之前
            {
                if(cr[i]==pr[j])//若现在的序列与之前的某一序列相同,就把原来的那一序列重置为0,避免了二次比较
                {
                    flag=0;
                    pr[j]='0';//重置为0
                    break;
                }
            }
            if(flag)//若是在当前数组位置i上,在原来数组中,都没有与这个对应相等的,那么这个号码一定要改变,数值加加
                sum++;
        }
        cout<<sum<<endl;
   
    return 0;
}

 

 类似资料:

相关阅读

相关文章

相关问答