Codehorses T-shirts

题目:

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;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值