ZOJ 3869 Ace of Aces
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
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— 2015浙江省赛的题目其中一题,不是很难。
题意:给出n张选票,算出得票数最多的人的id,如果有2个及以上的人都获得了最多的选票,则输出Nobody。
思路:计数题。设一个结构体,最后按照票数来排序即可。
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std; struct node
{
int id;
int cnt;
}a[]; bool cmp(node a, node b)
{
return a.cnt > b.cnt;
} int main()
{
//freopen("D:\\txt.txt", "r", stdin);
int n;
while (cin >> n)
{
while (n--)
{
memset(a, , sizeof(a));
int t,m;
int maxn = ;
cin >> t;
for (int i = ; i < t; i++)
{
cin >> m;
a[m].id = m;
a[m].cnt++;
}
sort(a, a + , cmp);
if (a[].cnt == a[].cnt) cout << "Nobody" << endl;
else cout << a[].id<<endl;
}
}
}
ZOJ 3869 Ace of Aces的更多相关文章
- 水题 ZOJ 3869 Ace of Aces
题目传送门 水题,找出出现次数最多的数字,若多个输出Nobody //#include <bits/stdc++.h> //using namespace std; #include &l ...
- 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 ...
- Ace of Aces
Description There is a mysterious organization called Time-Space Administrative Bureau (TSAB) in the ...
- 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 ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
随机推荐
- 学习Spark2.0中的Structured Streaming(一)
转载自:http://lxw1234.com/archives/2016/10/772.htm Spark2.0新增了Structured Streaming,它是基于SparkSQL构建的可扩展和容 ...
- [kx]为什么计算机能读懂 1 和 0 ?
CPU如何实现运算的? 下面是一个小伙的总结, 从物理电路到逻辑运算到数字电路,一步一步的好理解. 最好能看看那本<编码 隐匿在计算机软硬件背后的语言>的书. 为什么计算机能读懂 1 和 ...
- Python安装常见问题(1):zipimport.ZipImportError: can't decompress data
在CentOS以及其他的Linux系统中遇到安装包安装错误的原因,大多数都是因为缺少依赖包导致的,所以对于错误:zipimport.ZipImportError: can’t decompress d ...
- hdu1181 (变形课)简单地dfs
http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=259#problem/F Description 呃......变形课上Harr ...
- PAT 1054 The Dominant Color[简单][运行超时的问题]
1054 The Dominant Color (20)(20 分) Behind the scenes in the computer's memory, color is always talke ...
- 【Cocos2dx 3.3 Lua】剪裁结点ClippingNode
参考资料: http://shahdza.blog.51cto.com/2410787/1561937 http://blog.csdn.net/jackystudio/article/det ...
- Testbench结构篇
对于standalone的block的verification: 采用结构化的Testbench:Testcase与Harness,BFM分别分离,来提高系统的可重用性.如图是一个典型结构: 其中所有 ...
- ASIC中的一些库和文件类型
以下内容均来源于网络: 在进行综合,分析STA时,有几种库类型. NLDM: 非线性线载模型,最基本的dot lib. 电压源模型,cap值是单一值. 在90nm工艺以下,由于晶体管的特性变得很复杂 ...
- yii2增删改查及AR的理解
yii2增删改查 // 返回 id 为 1 的客户 $customer = Customer::findOne(1); // 返回 id 为 1 且状态为 *active* 的客户 $customer ...
- Root :: AOAPC I: Beginning Algorithm Contests (Rujia Liu) Volume 7. Graph Algorithms and Implementation Techniques
uva 10803 计算从任何一个点到图中的另一个点经历的途中必须每隔10千米 都必须有一个点然后就这样 floy 及解决了 ************************************* ...