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. c4d+ps打造抽象NFT加密艺术 Create Abstract NFT Crypto Art with Cinema 4D + Photoshop
  2. 【错误记录】Android Studio 编译报错 ( cannot open this project, please retry with version 4.2 or newer. )
  3. matlab生产计划问题,基于MATLAB的生产计划最优化系统设计
  4. 病例对照研究和队列研究详解
  5. android 获取应用的资源id和uri
  6. P6810 「MCOI-02」Convex Hull 凸包
  7. leetcode 278. 第一个错误的版本(二分)
  8. 服务器响应401,服务器返回HTTP响应代码:401,URL:https
  9. 2017.2.18 loli测试
  10. ceisum 加载geojson,webgl 加载geojson数据没有贴地
  11. python存储大量数据_如何在文件中密集地存储大量数据?
  12. 谷歌称已实现量子霸权;iOS 捷径功能被诉侵权;Chrome 78 Beta 发布 | 极客头条
  13. windows下将多个文件里面的内容合并成一个一个文件
  14. WPF框架下,窗体的嵌套显示
  15. 中航信E-Build基础API使用实例
  16. visio至word图片失真
  17. 金仓数据库字段_金仓数据库认证工程师(KCE)考试试题_含答案_
  18. openCV 实现用 python 画线、画矩形、画圆、画椭圆、画多边形
  19. Java代理模式:(二)代理模式
  20. Filter基础知识

热门文章

  1. Android studio之迁移定制出现Installation failed with message Failed to finalize session
  2. C和指针之auto和内存栈和register关键字
  3. C和指针之数组名和数组名和首元素以及sizeof(数组名)和sizeof(数组名作为参数)区别
  4. Android之jni出现JNIEnv has no member named ‘GetMehtodID‘解决办法
  5. linux C语言之called object ‘maze’ is not a function or function pointer printf(“%d\t“, maze(i, j))
  6. Linux之软连接和硬链接
  7. python画两条曲线_查找在matplotlib中绘制的两条曲线之间的区域(在区域之间填充)...
  8. 女朋友在家是怎么利用我的模型的​
  9. 宝塔linux面板假设nextcloud,宝塔面板部署NextCloud(14.0.3)逐一解决后台安全及设置警告...
  10. java float转换成long_在Java中如何将float转换为long或int数据类型?