HDU-2648(map的简单使用)
2020-04-07 11:48
106 查看
HDU-2648
题意:给出几天超市rank的增长,在每一天输出“memory”这个超市的排名;
思路:直接用map去映射每一个超市,然后在每一天用迭代器遍历出“memory”的排名(题目给了5000ms,所以遍历应该不超时)。
代码:
#include<iostream> #include<cstdlib> #include<sstream> #include<cstdio> #include<stack> #include<cstdio> #include<map> #include<set> #include<queue> #include<cstring> #include<cmath> #include<vector> #include<algorithm> using namespace std; typedef long long ll; #define me(a,b) memset(a,b,sizeof(a)) #define inf 0x3f3f3f3f const int N=1111122; const int M=200005; string s,s2="memory"; map<string,int> mp; int main() { int i,j,n,m,x; while(~scanf("%d",&n)) { mp.clear();//这了没有写,然后wa了5发。 for(i=1;i<=n;i++) { cin>>s; mp[s]=0; } map<string,int>::iterator it; cin>>m; while(m--) { int ans=0; for(i=1;i<=n;i++) { cin>>x>>s; mp[s]+=x; } for(it=mp.begin();it!=mp.end();it++) { if(it->second > mp[s2])ans++; } cout<<ans+1<<endl; } } system("pause"); return 0; }
相关文章推荐
- HDU 1228 A + B(map的简单使用)
- hdu 2648(map简单应用)
- hdu 2648(map简单应用)
- STL------list、set、map的简单使用
- Map控件的简单使用
- C++ 中map 中迭代器的简单使用:
- hdu 2072 单词数(map的简单应用)
- hdu 4941 map的使用
- hdu 1075 map的使用 字符串截取的常用手段 以及string getline 使用起来的注意事项
- HDU 1251(简单MAP字符串)
- c++ map简单使用
- HDU--1236 -- 排名 [使用库函数简单排序]
- Python 使用list实现简单的map
- HDU5496求整数序列的子串的并集和,map的简单使用
- 使用BitmapShader实现简单绘图
- java中几种Map的使用情况及其简单原理
- STL中map的简单使用
- HDU 2648 Shopping (map与迭代器)
- 母函数简介及简单使用(附HDU 1284 钱币兑换问题 解题报告)
- Android MapView简单使用