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 ...
随机推荐
- BZOJ 2730: [HNOI2012]矿场搭建( tarjan )
先tarjan求出割点.. 割点把图分成了几个双连通分量..只需dfs找出即可. 然后一个bcc有>2个割点, 那么这个bcc就不用建了, 因为一定可以走到其他救援出口. 只有一个割点的bcc就 ...
- BZOJ 1798: [Ahoi2009]Seq 维护序列seq( 线段树 )
线段树.. 打个 mul , add 的标记就好了.. 这个速度好像还挺快的...( 相比我其他代码 = = ) 好像是#35.. ---------------------------------- ...
- PHP学习笔记4-类/命名空间/成员方法/类方法
命名空间 namespace 类 class创建文件Hello.php,namespace是jikexueyuan: <?php /** * Created by PhpStorm. * U ...
- 【集训笔记】贪心算法【HDOJ1052 【HDOJ2037
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- MVC-03 控制器(4)
七.模型绑定 在ASP.NET MVC中是通过模型绑定(Model Binding)达到解析客户端传来的数据. 1.简单模型绑定 当网页上有个窗体,且窗体内有个名为Username的输入字段,而Act ...
- Cshap 使用http发起请求.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 using System; using System.I ...
- C语言之基本算法09—各位全是a的数列之和
/* ================================================================== 题目:数列为a,aa,aaa,--.求a+aa+aaa+-- ...
- 删除: warning C4996: 'sprintf': This function or variable may be unsafe. Consider 方法
可以使用的最简单的方法: 选项Project | Configuration Properties | C/C++ | Preprocessor | Preproc ...
- Hadoop 配置文件简介
1.core-site.xml文件 这是一个描述集群中NameNode结点的URI-统一资源标识符(包括协议,主机名称,端口号),集群里面的每一台机器都需要知道 NameNode的地址.DataNod ...
- Mac中QT程序发布
基于Qt开发的应用程序进驻Mac App Store 最近摸索着将一个基于用Qt开发的App发布到Mac App Store,在网上查找相关资料的时候,发现很多文档都过期了,要有一些修改,所以想记录下 ...