Ace of Aces
Description
There is a mysterious organization called Time-Space Administrative Bureau (TSAB) in the deep universe that we humans have not discovered yet. This year, the TSAB decided to elect an outstanding member from its elite troops. The elected guy will be honored with the title of "Ace of Aces".
After voting, the TSAB received N valid tickets. On each ticket, there is a number Ai denoting the ID of a candidate. The candidate with the most tickets nominated will be elected as the "Ace of Aces". If there are two or more candidates have the same number of nominations, no one will win.
Please write program to help TSAB determine who will be the "Ace of Aces".
Input
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:
The first line contains an integer N (1 <= N <= 1000). The next line contains N integers Ai (1 <= Ai <= 1000).
Output
For each test case, output the ID of the candidate who will be honored with "Ace of Aces". If no one win the election, output "Nobody" (without quotes) instead.
Sample Input
3
5
2 2 2 1 1
5
1 1 2 2 3
1
998
Sample Output
2
Nobody
998
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; int a[];
int f[]; int main()
{
int t,n,x,flag;
int maxx;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
memset(f,,sizeof(f));
maxx=-;flag=;
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
f[a[i]]++;
}
for(int i=;i<;i++)
{
if(f[a[i]]>maxx)
{
maxx=f[a[i]];
x=a[i];
}
}
for(int i=;i<;i++)
if(f[a[i]]==maxx&&a[i]!=x)
flag++;
if(flag>)
printf("Nobody\n");
else
printf("%d\n",x);
}
return ;
}
Ace of Aces的更多相关文章
- zjuoj The 12th Zhejiang Provincial Collegiate Programming Contest Ace of Aces
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5493 The 12th Zhejiang Provincial ...
- 第十二届浙江省大学生程序设计大赛-Ace of Aces 分类: 比赛 2015-06-26 14:25 12人阅读 评论(0) 收藏
Ace of Aces Time Limit: 2 Seconds Memory Limit: 65536 KB There is a mysterious organization called T ...
- ZOJ 3869 Ace of Aces
There is a mysterious organization called Time-Space Administrative Bureau (TSAB) in the deep univer ...
- 水题 ZOJ 3869 Ace of Aces
题目传送门 水题,找出出现次数最多的数字,若多个输出Nobody //#include <bits/stdc++.h> //using namespace std; #include &l ...
- 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(浙江省赛2015)
Ace of Aces Time Limit: 2 Seconds Memory Limit: 65536 KB There is a mysterious organization c ...
- 【windows 访问控制】十一、C# 实操 对象 System.Security.AccessControl 命名空间
AccessControl 命名空间 结构图 解说: DirectorySecurity=目录ACLFileSecurity=文件ACLFileSystemAuditRule=目录和文件中SACL中的 ...
- ACE的构建(VC++6.0环境)
ACE的构建(VC++6.0环境)Windows下ACE的构建1. 将ACE-5.5.zip解压到所需的安装目录,此处以E:/为例,解压后形成ACE_wrappers文件夹,因此ACE将会存在于ACE ...
- Windows Server 2008及以上系统磁盘无法查看(About UAC and ACE)
在windows Server2008及以上系統,如果UAC Enabled,ACE列表中不會包含Administrators成員的SID,所以即使你是administrators的成員,也無法訪問D ...
- Microsoft ACE OLEDB 12.0 数据库连接字符串
Excel 97-2003 Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myOldExcelFile.xls;Extended ...
随机推荐
- Android:AysncTask异步加载
以下是链接: http://blog.csdn.net/abc5382334/article/details/17097633 http://keeponmoving.iteye.com/blog/1 ...
- QGraphicsTextItem中的文字对齐
QGraphicsTextItem类可以放到QGraphicsScene或者QGraphicsItem上,用来显示格式化的文本内容,如HTML,当然纯文本也可以显示.如果只是显示纯文本,可以使用QGr ...
- PyQt中如何隐藏Menu
PyQt中隐藏一个Menu Item,可以通过QAction的setVisible(False)来设置,而QMenu的setVisible(False)是不管用的. 现在问题来了,我们有一个菜单,它有 ...
- POJ 1159 回文LCS滚动数组优化
详细解题报告可以看这个PPT 这题如果是直接开int 5000 * 5000 的空间肯定会MLE,优化方法是采用滚动数组. 原LCS转移方程 : dp[i][j] = dp[i - 1][j] + ...
- 1.unix网络编程基础知识
接触网络编程一年多了,最近在系统的学习vnp两本书,对基础知识做一些总结,希望理解的更透彻清晰,希望能有更多的沉淀. 1.套接口地址 针对IPv4和IPv6地址族,分别定义了两种类型的套接口地址:so ...
- iOS开发之计算动态cell的高度并缓存
项目中有个类似微博那样的动态cell,文字和图片的多少都不是确定的 刚开始使用autolayout,结果很多问题,最后我发现了一个框架 FDTemplateLayoutCell 写的很好,自动布局ce ...
- Python笔记之基本的语法
1 变量和赋值 Python是动态类型语言,不须要预先声明变量的类型.变量的类型在赋值的那一刻被初始化. Python变量名是大写和小写敏感的,即"cAsE"与"CaSe ...
- Hadoop SecondaryNameNode
[转] 1.概述 光从字面上来理解,很容易让一些初学者先入为主的认为:SecondaryNameNode(snn)就是NameNode(nn)的热备进程.X 其 实不是.snn是HDFS架构中的一 ...
- mysql各版本区别
MySQL 的官网下载地址:http://www.mysql.com/downloads/ 在这个下载界面会有几个版本的选择. 1. MySQL Community Server 社区版本,开源免费, ...
- GDOI2015——已成梦
今年GDOI(2015)在韶关北江中学(没记错的话应该是武江区)举行,感觉这五天就是一场梦,一场包含苦辣的梦. Day0 坐了一个上午的车,而且车内的空气又不好,感觉整个人都累倒下了. 到了北江之后吃 ...