ACM刷题之ZOJ————Ace of Aces
来源:互联网 发布:网站建设方案书 阿里云 编辑:程序博客网 时间:2024/06/06 03:03
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
352 2 2 1 151 1 2 2 31998
Sample Output
2Nobody998
2015浙江省赛水题
下面是ac代码
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>#include<map>#include<set>#include<queue>#include<string>#include<iostream>using namespace std;#define MID(x,y) ((x+y)>>1)#define CLR(arr,val) memset(arr,val,sizeof(arr))#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);const double PI = acos(-1.0);const int INF = 0x3f3f3f3f;const int N=2e5+7;struct dd{int val,cnt;};dd a[10000];int main(){//freopen("f:/input.txt", "r", stdin);int zu,i,j,k,x,cc,f,maxn,v,q;scanf("%d",&zu);while(zu--){CLR(a,0);scanf("%d",&k);cc=0;for(i=0;i<k;i++){scanf("%d",&x);f=0;for(j=0;j<cc;j++){if(a[j].val==x){f=1;++a[j].cnt;break;}}if(f==0){a[cc].val=x;++a[cc].cnt;++cc;}}maxn=-1;v=-1;for(i=0;i<cc;i++){if(maxn<a[i].cnt){maxn=a[i].cnt;v=a[i].val;}}q=0;for(i=0;i<cc;i++){if(maxn==a[i].cnt)++q;}if(q==1){printf("%d\n",v);}else{printf("Nobody\n");}}}
- ACM刷题之ZOJ————Ace of Aces
- A - Ace of Aces——ZOJ
- Ace of Aces ZOJ
- zoj 3869 Ace of Aces
- ZOJ 3869 Ace of Aces
- ZOJ-3869 Ace of Aces
- ZOJ 3869Ace of Aces
- ZOJ 3869-- Ace of Aces
- zoj-3869-Ace of Aces
- ACM-水题 Ace of Aces
- ZOJ Problem Set - 3869||Ace of Aces
- ZOJ - 3869 Ace of Aces (水)
- ZOJ 3869-Ace of Aces【模拟众数】
- ZOJ 3869:Ace of Aces【水】
- zoj 3869 Ace of Aces (水题)
- Ace of Aces
- ZOJ3869 Ace of Aces
- Ace of Aces
- 查询一个消息队列的状态,OSQQuery()
- 文档总结:linux中设备的访问
- HTML的第二天_HTML element
- 花神游历各国 bzoj3211 线段树
- iOS与Android对比学习之description方法
- ACM刷题之ZOJ————Ace of Aces
- 笔试技巧 java数据输入
- tensorflow42《TensorFlow实战》笔记-09-01 TensorBoard code
- bzoj 4814 [Cqoi2017]小Q的草稿
- LoadingBar
- nodejs模块之fs模块
- 动态规划-最大子矩阵
- 第七周leetcode题
- poj 1322 概率dp