BZOJ 2456: mode(巧取众数)
来源:互联网 发布:js获取frame 编辑:程序博客网 时间:2024/06/07 11:44
2456: mode
Time Limit: 1 Sec Memory Limit: 1 MBSubmit: 5043 Solved: 2110
[Submit][Status][Discuss]
Description
给你一个n个数的数列,其中某个数出现了超过n div 2次即众数,请你找出那个数。
Input
第1行一个正整数n。
第2行n个正整数用空格隔开。
Output
一行一个正整数表示那个众数。
Sample Input
5
3 2 3 1 3
3 2 3 1 3
Sample Output
3
HINT
100%的数据,n<=500000,数列中每个数<=maxlongint。
zju2132 The Most Frequent Number
Source
#include<map>#include<math.h>#include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> using namespace std;#define maxn 50005int main(void){int n,i;long long x,ans=0,num=0;scanf("%d",&n);for(i=1;i<=n;i++){scanf("%lld",&x);if(x==ans)num++;elsenum--;if(num<0)ans=x,num=1;}printf("%lld\n",ans);return 0;}
阅读全文
0 0
- BZOJ 2456: mode(巧取众数)
- 【bzoj 2456】 mode 众数
- BZOJ 2456 mode (求众数)
- bzoj 2456: mode(找众数)
- BZOJ 2456 mode(找众数)
- bzoj 2456: mode 【思维 求众数】
- [BZOJ 2456] mode 常数时间求众数/队列压缩
- 众数(Mode)
- bzoj 2456: mode (乱搞)
- 【bzoj 2456】mode(乱搞)
- BZOJ 2456 mode 【思维(入门)】
- bzoj 2456 mode 题解
- BZOJ 2456: mode
- bzoj 2456: mode
- bzoj 2456 mode
- bzoj--2456--mode(规律)
- BZOJ 2456: mode【思维】
- BZOJ 2456: mode【妙脆角】
- SpringBoot常用注解
- Java的File对象
- (转)王国斌:牛市还是熊市应该在意吗?
- mysql 错误 SQL Error: 1366: Incorrect string value: "\xE8\xAF\xA6\xE7\xBB\x86…" for column "address" a
- CF#418 Div2 D. An overnight dance in discotheque
- BZOJ 2456: mode(巧取众数)
- RTOS里的消息机制
- dbus-glib 详解
- Linux下查看系统版本信息
- RTOS里的任务切换
- 设计模式 装饰者模式 带你重回传奇世界
- WordPress在修改style.css样式不能立即生效
- vue文件在编辑器Sublime Text3中高亮
- sizeof运算符