2199. [HZOI 2016] 活动投票
2017-05-22 20:20
204 查看
★★ 输入文件:
时间限制:0.5 s
内存限制:2 MB
衡中活动很多,人也很多,一次活动有n个学生参与投票,现已知一名参赛选手票数超过半数,求其参赛号(参赛号随机)
第一行一个整数n
第二行n个整数Ni 代表第i个学生所投选手的参赛号
超过半数选手的参赛号
10
5 1 2 5 5 2 3 5 5 5
5
100%的数据中:n ≤3000000,1 ≤ Ni ≤300000000;
HZOI 2016
相同则加,不同则减
hztp.in输出文件:
hztp.out简单对比
时间限制:0.5 s
内存限制:2 MB
【题目描述】
衡中活动很多,人也很多,一次活动有n个学生参与投票,现已知一名参赛选手票数超过半数,求其参赛号(参赛号随机)
【输入格式】
第一行一个整数n第二行n个整数Ni 代表第i个学生所投选手的参赛号
【输出格式】
超过半数选手的参赛号
【样例输入】
105 1 2 5 5 2 3 5 5 5
【样例输出】
5
【提示】
100%的数据中:n ≤3000000,1 ≤ Ni ≤300000000;
【来源】
HZOI 2016相同则加,不同则减
#include<iostream> #include<cstdio> #include<cstring> #include<map> using namespace std; int n; int maxn; int num=1; int p; int main() { freopen("hztp.in","r",stdin); freopen("hztp.out","w",stdout); //ios::sync_with_stdio(false); //scanf("%d",&n); scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&p); if(p!=maxn) { num--; if(num<0) { maxn=p; num=1; } } else num++; } cout<<maxn; return 0; }
相关文章推荐
- COGS 2199. [HZOI 2016] 活动投票
- COGS 2199. [HZOI 2016] 活动投票
- php+mysql制作的投票功能 适合网站做问卷调查活动
- 微信朋友圈投票活动的刷票案例分析
- 「HZOI 2016」小象和老鼠
- CSDN博客投票活动开始了
- 计算机世界MSN群英语日投票活动
- OpenResty 2016技术大会——百格活动
- COGS 2416.[HZOI 2016]公路修建 & COGS 2419.[HZOI 2016]公路修建2 题解
- 「HZOI 2016」架设电话线路
- 活动反作弊服务_防羊毛党_防作弊评论_防刷单_防作弊投票_网易易盾
- 使用redis做一次投票活动中tomcat 启动一段时间后死机redis.clients.jedis.exceptions.JedisDataException: value sent to redi
- 数据结构(主席树):HZOI 2016 采花
- 有人@你 | ACMUG 2016 年会活动视频发布
- bitset [HZOI 2016]动物城的鸳鸯蛋传说
- 用c#开发微信 (17) 微活动 3 投票活动 (文本投票)
- COGS 2479. [HZOI 2016]偏序 [CDQ分治套CDQ分治 四维偏序]
- 「HZOI 2016」最长公共上升子序列
- cogs2632. [HZOI 2016]数列操作d
- 【COGS2479】 HZOI2016—偏序