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 ...
随机推荐
- corethink功能模块探索开发(三)让这个模块可见
感觉corethink把thinkphp的思想复用到淋漓尽致. 1.把opencmf.php文件配置好了后台该模块的菜单就能在安装后自动读取(分析好父子关系,否则页面死循环,apache资源占用率10 ...
- LeetCode-day01&02
感觉还好,坚持住就行,毕竟智商不够 1. Length of Last Word求一个数组的最后一个单词的长度 2. Plus One 大数加1 3. Add Binary 二进制加法 4. S ...
- 剑指offer 面试39题
面试39题: 题目:数组中出现次数超过一半的数字 题:数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字.例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}.由于数字2在数组中 ...
- vim tabs
:tabnew 增加一个标签:tabc 关闭当前的tab:tabo 关闭所有其他的tab:tabs 查看所有打开的tab:tabp 或gT 前一个:tabn 或gt 后一个:tabfirst或:tab ...
- 解释python中的help()和dir()函数
help函数是一个内置函数,用于查看函数或模块用途的详细说明 import copy print(help(copy.copy)) Help on function copy in module co ...
- python之路 模块,序列化,迭代器,生成器
一.模块 1.模块简介 模块是一个包含所有你定义的函数和变量的文件,其后缀名是.py.模块可以被别的程序引入,以使用该模块中的函数等功能.这也是使用python标准库的方法. 类似于函数式编程和面向过 ...
- UI控件之UIView与动画
UIView:用来展示用户的界面,响应用户的操作(继承自UIResponder) UIView的作用:绘图.动画.处理事件 UIView可以包含和管理子视图,并且决定子视图的位置大小 获取所有的子视图 ...
- 023_数量类型练习——Hadoop MapReduce手机流量统计
1) 分析业务需求:用户使用手机上网,存在流量的消耗.流量包括两部分:其一是上行流量(发送消息流量),其二是下行流量(接收消息的流量).每种流量在网络传输过程中,有两种形式说明:包的大小,流量的大小. ...
- [转]springmvc中的常用的返回
package com.boventech.learning.controller; import java.util.HashMap; import java.util.Map; import or ...
- centos7 下安装eclipse
1 在下面路径下载 eclipse-jee-neon-2-linux-gtk-x86_64.tar.gzhttp://eclipse.stu.edu.tw/technology/epp/downloa ...