codeforces1000a csdn-博客

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.

  • 题意:给你两组字符串,求把第一组字符串装换成第二组时要变化多少次。其中字符串形式是固定的几种,且变化时不能增多也不能减少。

  • 解题思路:根据题意,当字符串长度为一时,有不同的情况。因此,可以把字符串为一的字符单独记录有多少个,然后比较即可。对于长度不是一的,可以每个不同的只需变化一次,排序后一次比较即可,也可以单独记录比较。

#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
using namespace std;
int n;
vector<string>g[4],h[4];
int a1=0,a2=0,a3=0,b1=0,b2=0,b3=0;
int main()
{cin>>n;for(int i=0;i<n;i++){string s;cin>>s;if(s.size()==1){if(s=="M")a1++;if(s=="S")a2++;if(s=="L")a3++;continue;}g[s.size()-1].push_back(s);}for(int i=0;i<n;i++){string s;cin>>s;if(s.size()==1){if(s=="M")b1++;if(s=="S")b2++;if(s=="L")b3++;continue;}h[s.size()-1].push_back(s);}sort(g[1].begin(),g[1].end());sort(g[2].begin(),g[2].end());sort(g[3].begin(),g[3].end());sort(h[1].begin(),h[1].end());sort(h[2].begin(),h[2].end());sort(h[3].begin(),h[3].end());int ans=0;ans=a1+a2+a3-min(a1,b1)-min(a2,b2)-min(a3,b3);for(int i=0;i<g[1].size();i++){if(g[1][i]!=h[1][i]){ans++;}}for(int i=0;i<g[2].size();i++){if(g[2][i]!=h[2][i]){ans++;}}for(int i=0;i<g[3].size();i++){if(g[3][i]!=h[3][i]){ans++;}}cout<<ans<<endl;return 0;
}

posted @ 2018-07-02 09:42 i-Curve 阅读(...) 评论(...) 编辑 收藏

codeforces1000a csdn-博客相关推荐

  1. 关于博客园与CSDN博客同步的说明

    把博客园与CSDN比较,我认为博客园有技术内容优势,CSDN有行业资源优势,两者都比较重要.因此在两家网站同步发布博客. CSDN博客地址:http://blog.csdn.net/caoshiyin ...

  2. 2019年度CSDN博客之星TOP10榜单揭晓,你上榜了吗?

    培根说,『读书造成充实的人,会议造成未能觉悟的人,写作造成正确的人』. 在短信短视频快速迭代的快时代,更深度的思考.更正确的实践,更成体系的写作与分享,尤显可贵.这里,每一篇博文都是开发者实战的经验解 ...

  3. CSDN博客的创建及使用

    文章目录 一.创建CSDN博客详细流程 1. 注册 2. 绑定手机 二.编辑和发布博客 1. 设置markdown格式 2. 发布文章 3. 常见的markdown语法 3.1 分级标题 3.2 目录 ...

  4. 这是一名南京985AI硕士,CSDN博客专家

    微信公众号推荐 AI蜗牛车公众号 微信公众号<AI蜗牛车>,公众号致力于技术项目化,具体化,思考化,会写系列的项目工程文章,细致到位,也会写一个读物的读书笔记,或者一个语言/框架的学习笔记 ...

  5. CSDN博客获取积分规则!不是下载积分!如何快速增长积分!

    博客积分是CSDN对用户努力的认可和奖励,也是衡量博客水平的重要标准. 博客等级也将由博客积分唯一决定.积分规则具体如下: 1.每发布一篇原创或者翻译文章:可获得10分: 2.每发布一篇转载文章:可获 ...

  6. 类选择器和所作用的标签一起写为什么不起作用? - CSDN博客

    原文:类选择器和所作用的标签一起写为什么不起作用? - CSDN博客 HTML代码: css样式: 这不是将样式作用于circle类下的有current类的li标签吗?为什么不起作用? 原因: 选择器 ...

  7. microsoft edge 打不开 csdn 博客

    microsoft edge 打不开 csdn 博客

  8. 如何转载别人的csdn博客

    起意 看到一篇不错的博客,想转载但是不会(没有转载键),网搜发现没有Chrome浏览器的详细转载办法,受博主Bily猪启发,弄了这个教程,给小白的,大神勿嗤.时间紧急的直接看总结. 实践 检查.在喜欢 ...

  9. 如何在简历中添加自己的CSDN博客链接

    如何在简历中添加自己的CSDN博客链接 添加以下网址https://blog.csdn.net/ID(ID为 ) 点开就是自己的博客

  10. ​kdevelop用法_weixin_44594953的博客-CSDN博客_kdevelop​

    kdevelop用法_weixin_44594953的博客-CSDN博客_kdevelop

最新文章

  1. Hibernate映射解析——七种映射关系
  2. PHP多种序列化/反序列化的方法(serialize和unserialize函数)
  3. 每日一皮:资深程序员调试代码的样子...
  4. JavaScript Binding
  5. NSNotification、delegate和KVO的区别
  6. LeakCanary,检测安卓,java内存泄漏
  7. 行为设计模式 - 模板方法设计模式
  8. spring 锁_分布式锁-快速实战
  9. EasyPR--中文车牌识别系统 开发详解(开源)
  10. 数据库没有备份---应如何还原丢失的数据
  11. Appium 控件定位链接整理(appiumdriver)
  12. 用计算机怎么按四分之三次方等于多少,八十一分之十六的负四分之三次方怎么算,要具体过程,答案是多少?...
  13. 利用广播星历解算北斗卫星位置及精度分析
  14. 笔记本安装双系统教程
  15. 【题解】【AcWing】1526. 洗牌机
  16. 基于传统方法的单目深度估计
  17. 恒瑞、百济之外,再鼎开辟了中国医药创新又一极
  18. 服务器系统对比、数据库对比、后台开发语言对比
  19. unrecognized or represents more than one time zone
  20. IDM UEStudio 19中文版

热门文章

  1. 为 Nexus 5 准备的 Sailfish 移植版本
  2. 找回桌面清理向导清理多余IE图标
  3. 音频混音接口调节音量及设置静音
  4. 软件企业(ISV)的那些管理门道
  5. 【SSR】287- 从头开始,彻底理解服务端渲染原理
  6. 《趣学Python——教孩子学编程》——第1部分 学习编程 第1章 Python不是大蟒蛇 1.1 关于计算机语言...
  7. v-chart 自定义显示格式
  8. 如何使用 Echarts 和 SVG文件写大屏可视化地图 ?
  9. im2col函数实现超级详细解释
  10. 数据堂-数加加众包任务招募啦~!说方言,来赚钱