ZCMU-1773-Mode
2017-01-02 13:07
204 查看
1773: Mode
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 77 Solved: 28
[Submit][Status][Web
Board]
Description
Give you a number of n series, in which a number of more than n / 2 times , you should find out that the number (n<=500000,x<=10^19)Input
The first line is a positive integer n. The second line of n positive integers separated by spaces.Output
A Positive integer on a line indicates that numberSample Input
53 2 3 1 3
Sample Output
3【解析】
题目大意,给你一个序列叫你输出出现序列的次数超过n/2次的数,每输出一个换行,看到这么大的数据我直接用map
#include<cstdio> #include<iostream> #include<algorithm> #include<map> #include<string> using namespace std; map<long long,int>a; int main() { int n; long long p; while(~scanf("%d",&n)) { a.clear(); for(int i=0;i<n;i++) { scanf("%lld",&p); if(a[p]!=-1) a[p]+=1; if(a[p]>n/2) { printf("%lld\n",p); a[p]=-1; } } } return 0; }
相关文章推荐
- Paint PorterDuff及Xfermode详解
- Assembly之instruction之Register Mode
- 使用emacs的org-mode进行时间管理(六)——tags
- PorterDuffXfermode的用法
- UIViewContentMode
- 20150612_Andriod contextual action mode 菜单
- 控件textbox的TextMode="MultiLine"时的限制字数多少问题
- php中安全模式safe_mode配置教程
- [Code VS 1773]创新吃鱼法
- android activity launchmode
- [Elasticsearch] 控制相关度 (五) - function_score查询及field_value_factor,boost_mode,max_mode参数
- Android中的windowSoftInputMode属性详解
- [CortexM0--stm32f0308]Low Power Mode
- STM32 microcontroller system memory boot mode
- Your CPU does not support long mode. Use a 32 bit distribution.
- NBUT 1225 NEW RDSP MODE I (规律+快速幂)
- ASP.NET 4.0引入的视图状态属性ViewStateMode与原EnableViewState的区别
- 【水】【卡内存】【bzoj 2456】mode
- Android android:windowSoftInputMode 属性整理
- android EditText长按屏蔽ActionMode context菜单但保留选择工具功能