hdoj-1004-Let the Balloon Rise(map排序)
map按照value排序
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
#include <utility>
using namespace std;
typedef pair<string, int> PAIR;
bool cmp_by_value(const PAIR& lhs, const PAIR& rhs) {
return lhs.second > rhs.second;
}
map<string ,int> ship;
int main() {
int n;
while (cin>>n, n) {
ship.clear();
for (int i=; i<n; i++) {
string tmp;
cin>>tmp;
ship[tmp]++;
}
vector<PAIR> vec(ship.begin(), ship.end());
sort(vec.begin(), vec.end(), cmp_by_value);
cout<<vec.begin()->first<<endl;
}
return ;
}
hdoj-1004-Let the Balloon Rise(map排序)的更多相关文章
- HDU 1004 Let the Balloon Rise map
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- HDOJ 1004 Let the Balloon Rise (字符串+stl)
题目: Problem Description Contest time again! How excited it is to see balloons floating around. But t ...
- HDOJ 1004 Let the Balloon Rise
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
- HDU 1004 Let the Balloon Rise(map应用)
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
- HDU 1004 Let the Balloon Rise(map的使用)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...
- hdu 1004 Let the Balloon Rise(字典树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...
- HDU 1004 Let the Balloon Rise【STL<map>】
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- hdu 1004 Let the Balloon Rise strcmp、map、trie树
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- 杭电1004 Let the Balloon Rise
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
随机推荐
- spring中配置缓存—ehcache
常用的缓存工具有ehcache.memcache和redis,这里介绍spring中ehcache的配置. 1.在pom添加依赖: <!-- ehcache 相关依赖 --> <de ...
- 2.4 使用ARDUINO控制MC20进行GPS数据的获取和解析
需要准备的硬件 MC20开发板 1个 https://item.taobao.com/item.htm?id=562661881042 GSM/GPRS天线 1根 https://item.taoba ...
- 【转】Python爬虫(1)_基本原理
一 爬虫是什么 #如果我们把互联网比作一张大的蜘蛛网,数据便是存放于蜘蛛网的各个节点,而爬虫就是一只小蜘蛛,沿着网络抓取自己的猎物/数据 #爬虫指的是:向网站发起请求,获取资源后分析并提取有用数据的程 ...
- offsetHeight+scrollHeight+clientHeight
ch 窗口可见区域高度 :ch = padding + height(height不是所有内容的高度,是样式定义的高度) oh border以内的内容高度: oh = border + padding ...
- commonAncestor
commonAncestor 光标或选区所在区域最外层的祖先节点
- iOS 快速遍历 效率分析 for loop for in enumerateBlock 适用条件
test1 简单遍历 结论: 当数组数据量很小 时候 for loop 和 for in 效率不相上下,随着数据量增长for in 快速枚举的优势 明显 如果需要知道 索引可用 enumrateBlo ...
- $ python正则表达式系列(1)——正则元字符
本文主要介绍python中正则表达式的基本用法,做一个初步的认识. 1. 初识 python通过re内置模块来处理正则表达式(regex),底层使用C引擎.一个简单的正则匹配的例子: import r ...
- finally中的return
周五晚6点下班去面试,出了一份笔试题,看到第一题有些蒙了,虽然以前遇到过类似的问题,但并没有留心记一下,觉得没人会这样写代码,但实际上没有面试题中是有的. 1,有在try块中执行不到finally的情 ...
- Linux 调优
一.系统优化 1.硬件优化 增加内存 更换速度跟高磁盘(sata->sas)可以增加固态硬盘 更换更高校率的网卡,或者双网卡绑定,两个网卡作为一个网卡使用.服务器网卡一般为千兆 2.系统层优化 ...
- PHP递归和非递归遍历文件夹下文件
function readDirFiles($dir){ $files= []; $queue=[realpath($dir)]; $currentPath = current($queue); wh ...