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. maven杂碎汇总

        本来是想写一篇关于maven知识点的详细总结的,但需要看一本书或教材,然后再汇总一下,这样做自然是好的,这个在年前争取做完.本文是主要记录在工作和学习遇到关于maven的一些困惑.很乐意看到它 ...

  2. mysql实现ORACLE的connect by prior父子递归查询

    oracle中有connect by prior ,可以实现父子递归查询.而mysql中没有这种功能,但我们可以变通实现. 比如一个表: Table Name: tb_Tree Id | Parent ...

  3. 图片与byte相互转换

    一.图片转byte public byte[] ImageToByte() { string imagefile = @"http://192.168.0.212/pass/T-1.jpg& ...

  4. delphi的dbgrid控件点击title排序

    procedure TfrmMain.DBGridEhTitleClick(Column: TColumnEh);var i : integer;begin for i:= 1 to DBGridEh ...

  5. Phoenix5.0的部署

    官网下载编译好的二进制包 http://phoenix.apache.org/download.html2 上传并解压到指定目录, 再修改目录名称 tar -zxvf apache-phoenix-5 ...

  6. openssl生成CA签署 及 加密解密基础

    openssl  生成私有CA 及签署证书 openssl 配置文件: /etc/pki/tls/openssl.cnf 1. 在openssl CA 服务器端生成私钥 cd /etc/pki/CA/ ...

  7. Bookshelf 2 简单DFS

    链接:https://ac.nowcoder.com/acm/contest/993/C来源:牛客网 题目描述 Farmer John recently bought another bookshel ...

  8. JuJu团队12月2号工作汇报

    JuJu团队12月2号工作汇报 JuJu   Scrum 团队成员 今日工作 剩余任务 困难 于达 和婷婷一起调试main.jl 继续调试 金华实现的BiLSTM参数无法使用save存入 婷婷 和于达 ...

  9. 一个基于chrome扩展的自动答题器

    1.写在前面 首先感谢小茗同学的文章-[干货]Chrome插件(扩展)开发全攻略, 基于这篇入门教程和demo,我才能写出这款 基于chrome扩展的自动答题器. git地址: https://git ...

  10. Go——标准库使用代理

    本文知识点 Go的安装 Go使用代理 Go进阶学习 环境配置 Go的安装 确认环境都安装好了,看看go的版本. go version 代码样例 使用代理,发送GET请求 package main im ...