A - Ace of Aces——ZOJ

A - Ace of Aces

Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld
& %llu

Submit Status

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<stdio.h>
#include<string.h>
#define MAX 2000
typedef struct node{
	int v;
	int c;
}NODE;
int main()
{
	int n,m,v[MAX],t,i,j,max,maxx,k,flag;
	NODE que[1005];
	scanf("%d",&n);
	for(k=1;k<=n;k++)
	{
		flag=0;
		memset(v,0,sizeof(v));
		scanf("%d",&m);
		for(i=1;i<=m;i++)
		{
			scanf("%d",&t);
			v[t]++;
		}
		int len=0;
		for(i=1;i<MAX;i++)
		{
			if(v[i])
			{
				que[len].c=i;
				que[len].v=v[i];
				len++;
			}
		}
		max=0;
		for(i=0;i<len;i++)
		{
			if(max<que[i].v)
			{
				max=que[i].v;
				maxx=que[i].c;
				t=i;
			}
		}

		int temp=max;
		int tempx=maxx;
		que[t].v=-1;

		max=0;
		for(i=0;i<len;i++)
		{
			if(max<que[i].v)
			{
				max=que[i].v;
				maxx=que[i].c;
			}
		}

		if(max==temp)
			printf("Nobody\n");
		else
			printf("%d\n",tempx);
	}
	return 0;
}
时间: 2025-01-18 05:38:36

A - Ace of Aces——ZOJ的相关文章

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 g

2015浙江省赛

ZOJ 3872 :Beauty of Array 对于每个数,计算这个数被累加的次数.找到这个数左边这个数出现的地方,在这之间的所有数的数量*这个数后面的数的数量,即为这个数被计算的次数 <code class="hljs cpp has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pr

ZOJ-3869

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 h

ACE的构建(VC++6.0环境)

ACE的构建(VC++6.0环境)Windows下ACE的构建1. 将ACE-5.5.zip解压到所需的安装目录,此处以E:/为例,解压后形成ACE_wrappers文件夹,因此ACE将会存在于ACE_wrappers/ace目录中.ACE_ROOT=E:/ACE_wrappers.2. 在系统中新建ACE_ROOT环境变量,值设为 E:/ACE_wrappers.具体设置为:我的电脑->属性->高级->环境变量->新建3. 在E:/ACE_wrappers/ace目录中创建一个头

Windows Server 2008及以上系统磁盘无法查看(About UAC and ACE)

在windows Server2008及以上系統,如果UAC Enabled,ACE列表中不會包含Administrators成員的SID,所以即使你是administrators的成員,也無法訪問D盤! 解决方法参考如下文章: Changes to tokens When a user who is a member of the Administrators group in Windows® XP or Windows Server 2003 logs on to a computer,

jeecg 3.5.2 新版本4种首页风格 【经典风格,shortcut风格,ACE bootstrap风格,云桌面风格】

[1]经典风格: [2]Shortcut风格: [3]ACE bootsrap风格: [4]云桌面风格: [5]自定义图表 [6].系统监控

【阿里云产品公测】以开发者角度看ACE服务『ACE应用构建指南』

?;ZnD(4?   评测介绍 1V-sibE   j|LOg 评测产品: 云引擎ACE服务 开发语言: PHP 评测人: mr_wid 评测时间: 2014年10月13日-19日 XV1XzG#C   .>p.k*vU   评测概要 9]:F!d/   fYlqaO4[   非常有幸能够申请到ACE的公测资格, 在本篇评测中, 笔者将以一个开发者的角度来对云引擎ACE服务进行介绍与使用.在本篇评测中, 您将看到: ACE能够做些什么 ACE应用的创建与发布 应用的配置与调试 ACE扩展服务的使

概率dp ZOJ 3640

Help Me Escape Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3640 Appoint description:  System Crawler  (2014-10-22) Description Background     If thou doest well, shalt thou not be accepted? an

zoj 2156 - Charlie&#39;s Change

题目:钱数拼凑,面值为1,5,10,25,求组成n面值的最大钱币数. 分析:dp,01背包.需要进行二进制拆分,否则TLE,利用数组记录每种硬币的个数,方便更新. 写了一个 多重背包的 O(NV)反而没有拆分快.囧,最后利用了状态压缩优化 90ms: 把 1 cents 的最后处理,其他都除以5,状态就少了5倍了. 说明:貌似我的比大黄的快.(2011-09-26 12:49). #include <stdio.h> #include <stdlib.h> #include <