Problem Description
Every girl likes shopping,so does dandelion.Now she finds the shop is increasing the price every day because the Spring Festival is coming .She is fond of a shop which is called “memory”. Now she wants to know the rank of this shop’s price after the change of everyday.

Input
One line contians a number n ( n<=10000),stands for the number of shops.
Then n lines ,each line contains a string (the length is short than 31 and only contains lowercase letters and capital letters.)stands for the name of the shop.
Then a line contians a number m (1<=m<=50),stands for the days .
Then m parts , every parts contians n lines , each line contians a number s and a string p ,stands for this day ,the shop p 's price has increased s.

Output
Contains m lines ,In the ith line print a number of the shop “memory” ‘s rank after the ith day. We define the rank as :If there are t shops’ price is higher than the “memory” , than its rank is t+1.

Sample Input

3
memory
kfc
wind
2
49 memory
49 kfc
48 wind
80 kfc
85 wind
83 memory

Sample Output

1
2

解题思路:
map容器模拟即可!!!

代码如下:

#include <iostream>
#include <map>
#include <string>
using namespace std;
map<string, int>shop;
map<string, int>::iterator it;
int n, m;int main() {while (cin >> n) {string s;for (int i = 1; i <= n; i++)cin >> s;cin >> m;while (m--) {for (int i = 1; i <= n; i++) {int a;cin >> a >> s;shop[s] += a;}int rank = 1;for (it = shop.begin(); it != shop.end(); it++) {if (it->second > shop["memory"]) {rank++;}}cout << rank << endl;}shop.clear();}return 0;
}

hdu2648 Shopping-map容器相关推荐

  1. Map容器大小影响key的索引

    单元测试偶然发现的Map一个问题 Map<String,String> map1 = new HashMap<>();map1.put("aaa", &qu ...

  2. CSU 1113 Updating a Dictionary(map容器应用)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1113 解题报告:输入两个字符串,第一个是原来的字典,第二个是新字典,字典中的元素的格式为 ...

  3. C++中map容器的说明和使用技巧

    C++中map容器提供一个键值对容器,map与multimap差别仅仅在于multiple允许一个键对应多个值. 1   头文件 #include <map> 2   定义 map< ...

  4. HDU 2094 产生冠军 (map容器)

    title: 产生冠军 杭电 2094 tags: [acm,stl] 题目链接 Problem Description 有一群人,打乒乓球比赛,两两捉对撕杀,每两个人之间最多打一场比赛. 球赛的规则 ...

  5. leetcode(3)——697. 数组的度(C++版本注释)(map容器),448. 找到所有数组中消失的数字(取余操作,C++中的auto类型)

    文章目录 前言 697 程序 思路 收获 map容器 448 程序 收获 取模操作的思考 auto 前言 大佬的程序,边刷边总结边学语言. 题目697 697 程序 class Solution {p ...

  6. c++ map 修改value_C++知识分享之STL容器:set 容器与 map 容器的简单应用

    set容器中一些函数,取自百度其他大佬已总结好的,如有侵权,请联系删除! set的各成员函数列表如下: c++ stl容器set成员函数:begin()--返回指向第一个元素的迭代器 c++ stl容 ...

  7. C++map容器遍历删除:cannot increment value-initialized map/set iterator

    今天写C++结课作业遇到一个遍历删除的bug: 原代码: for(it=imap.begin();it!=imap.end();it++) imap.erase(it) 运行后: 第一次循环末尾,it ...

  8. map容器中删除一个元素(value)

    一:问题描述 我们想要删除map容器中,一个key值对应的vlaue 二:上码 #include<iostream> #include<map> #include<vec ...

  9. map容器的使用 逆序遍历map容器当中的数据

    一:前言 这个逆序遍历是将map容器的迭代器进行了变化,reverse_iterator逆向遍历的迭代器 ,它需要 rbegin()和rend()方法指出反向遍历的 起始位置和终止位置. 二:上码演示 ...

  10. [NOIP2008 提高组] 笨小猴-map容器用来标记

    题目描述 笨小猴的词汇量很小,所以每次做英语选择题的时候都很头疼.但是他找到了一种方法,经试验证明,用这种方法去选择选项的时候选对的几率非常大! 这种方法的具体描述如下:假设maxn是单词中出现次数最 ...

最新文章

  1. PHP微信开发之获取access_token
  2. 先考学历还是先提升能力?
  3. 19款绚丽实用的jQuery/CSS3侧边栏菜单
  4. LiveVideoStack线上分享第五季(八):播放器的极致体验优化
  5. jvm虚拟机内存结构_JVM体系结构101:了解您的虚拟机
  6. php static_castunsigned int,static_cast揭密
  7. 数据离散化之chimerge算法的实现(python版)(以莺尾花数据为例)
  8. OpenGL: gluLookAt函数的含义
  9. 安全科普:流量劫持的方式和途径
  10. 一般3d模型代做多少钱_3d打印一个模型多少钱
  11. 阶乘数的快速计算方法
  12. 生产者消费者问题的C语言实现
  13. textblob 情感分析_使用TextBlob进行远程学习的推文中的情感分析
  14. MQ 系列之 ActiveMQ 介绍
  15. 论文阅读”Ada-nets: Face clustering via adaptive neighbour discovery in the structure space“
  16. 权威解读 GitHub、Apache 疑云:主流开源软件究竟是否会被闭源?
  17. PHP 接口和抽象类的区别
  18. java 发送邮件嵌套HTML模板 (二)
  19. 云计算之路-阿里云上:超级奇怪的“黑色10秒钟”
  20. 微信小程序 图片 文字 敏感内容验证 获取小程序accessToken

热门文章

  1. toolStripButton调整大小并只显示text
  2. C和指针之字符串编程练习11(统计一串字符包含the的个数)
  3. C语言之unsigned char和uint8_t
  4. Android之属性动画初步
  5. 我使用 html 反向输出自己打自己(7)
  6. d类功放芯片_应用于无滤波级D类音频功放的新型死区时间控制系统
  7. linux算法设计,嵌入式Linux平台下随机序列算法设计.doc
  8. 二进制全排列 java_排列组合算法真厉害,傻瓜都能学会
  9. 高考成绩接近满分,却被清华北大拒绝,被称“中国最帅科学家”
  10. 用一个小球揭开地球的面纱,探索地球运转的秘密!