https://codeforces.com/problemset/problem/1000/A

题意:

有n个人,给出每个人的衣服的尺码,现在,将这n件衣服的尺码换成另外的n种尺码,如果有尺码一样的衣服,则不需要换,问,最少需要更换几件衣服。

思路:

map记录一下每种尺码的衣服出现的次数,然后对新尺码进行一一比对,如果新尺码的数量大于原有的,则说明要更换数量为二者差值的衣服。

代码: 

 #include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
const int INF=0x3f3f3f3f;
typedef long long LL;
const int mod=1e9+;
const int maxn=1e5+;
using namespace std; int main()
{
int n;
cin>>n;
map<string,int> mp1,mp2;
map<string,int>::iterator it;
string str;
int num=;
for(int i=;i<=n;i++)
{
cin>>str;
mp1[str]++;
}
for(int i=;i<=n;i++)
{
cin>>str;
mp2[str]++;
}
for(it=mp2.begin();it!=mp2.end();it++)
{
if(it->second>mp1[it->first])
num+=it->second-mp1[it->first];
}
printf("%d\n",num);
return ;
}

CodeForces 1000A Codehorses T-shirts(STL map、思维)的更多相关文章

  1. stl::map之const函数访问

    如何在const成员数中访问stl::map呢?例如如下代码: string ConfigFileManager::MapQueryItem(const string& name) const ...

  2. hdu4941 Magical Forest (stl map)

    2014多校7最水的题   Magical Forest Magical Forest Time Limit: 24000/12000 MS (Java/Others)    Memory Limit ...

  3. [CareerCup] 13.2 Compare Hash Table and STL Map 比较哈希表和Map

    13.2 Compare and contrast a hash table and an STL map. How is a hash table implemented? If the numbe ...

  4. STL MAP及字典树在关键字统计中的性能分析

    转载请注明出处:http://blog.csdn.net/mxway/article/details/21321541 在搜索引擎在通常会对关键字出现的次数进行统计,这篇文章分析下使用C++ STL中 ...

  5. POJ 3096 Surprising Strings(STL map string set vector)

    题目:http://poj.org/problem?id=3096 题意:给定一个字符串S,从中找出所有有两个字符组成的子串,每当组成子串的字符之间隔着n字符时,如果没有相同的子串出现,则输出 &qu ...

  6. STL MAP 反序迭代

    ITS_NOTICE_MAP::reverse_iterator it = noticeMap.rbegin(); for ( ; it != noticeMap.rend(); ++it ) { I ...

  7. 泛型Binary Search Tree实现,And和STL map比较的经营业绩

    问题叙述性说明: 1.binary search tree它是一种二进制树的.对于key值.比当前节点左孩子少大于右子. 2.binary search tree不是自平衡树.所以,当插入数据不是非常 ...

  8. Dictionary,hashtable, stl:map有什么异同?

    相同点:字典和map都是泛型,而hashtable不是泛型. 不同点:三者算法都不相同 Hashtable,看名字能想到,它是采用传统的哈希算法:探测散列算法,而字典则采用的是散列拉链算法,效率较高, ...

  9. Codeforces Round #546 (Div. 2) D 贪心 + 思维

    https://codeforces.com/contest/1136/problem/D 贪心 + 思维 题意 你面前有一个队列,加上你有n个人(n<=3e5),有m(m<=个交换法则, ...

随机推荐

  1. eshop1-大型电商架构演进

    1. 项目初期 2. 服务器分离 以上的服务分离架构,即使文件服务crash 了,但是application server 和 Database Server 继续可以访问运行 3. 基于并发访问越来 ...

  2. docker安装并设置开机启动(Linux)

    docker 开机启动: systemctl enable docker 使用的linux系统为CentOS7.2 docker分为CE和EE版本,EE版本收费,一般我们使用CE版本就满足要求了 do ...

  3. java格式化代码(java格式化代码工具类)

    下别人的原来链接..... 支持效果不好要想格式化好需要解析语法树   7个积分我这里免费下      转自 https://download.csdn.net/download/jkl012789/ ...

  4. Spring boot application.properties和 application.yml 初学者的学习

    来自于java尚硅谷教程 简单的说这两个配置文件更改配置都可以更改默认设置的值比如服务器端口号之类的,只需再文件中设置即可, properties可能是出现的比较早了,如果你不调你的默认编码,中文可能 ...

  5. TBLASTN

    TBLASTN search translated nucleotide databases using a protein query

  6. centos6.5搭建hadoop单节点

    1.添加用户 groupadd  hadoop useradd -d /home/hadoop -m hadoop -g hadoop passwd hadoop    修改密码 付给用户sudo权限 ...

  7. 虚拟化安全服务器のIP修改配置

    1)进入网卡配置文件目录(以centos7.6为例) cd /etc/sysconfig/network-scripts     2)编辑配置文件(根据自己机器实际网卡进行编辑), 如Vi ifcfg ...

  8. 070-PHP数组相加

    <?php $arr1=array('a','b','c'); //定义一个数组 echo '数组$arr1的信息:<br />'; print_r($arr1); //输出数组信息 ...

  9. oracle11g导出dmp文件时不能导出空表,导致缺表

    一.执行 select 'analyze table '||table_name||' compute statistics;' from user_tables; 将该查询语句查询到的结果粘贴到sq ...

  10. (20)sopel算法

    基础知识的理论,主要看这个博客:https://blog.csdn.net/github_38140310/article/details/68959931 然后代码展示: #include &quo ...