【CUGBACM15级BC第20场 A】hdu 5123 who is the best?
来源:互联网 发布:手机淘宝撤销投诉 编辑:程序博客网 时间:2024/05/22 16:56
who is the best?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1117 Accepted Submission(s): 668
Total Submission(s): 1117 Accepted Submission(s): 668
Problem Description
There are N people want to choose the best person. Each person select the best personai , .John wants to know that who received the most number of votes.
Input
The first line contains a single integerT(1≤T≤50) ,indicating the number of test cases.
Each test case begins with an integerN(1≤N≤100) ,indicating the number of person.
Next N lines contains an integerai(1≤ai≤N) .
Each test case begins with an integer
Next N lines contains an integer
Output
For each case, output an integer means who is the best person. If there are multiple answers, print the minimum index.
Sample Input
21012345678910533333
Sample Output
13
水题没啥好说的
#include <iostream>#include <set>#include <map>#include <stack>#include <cmath>#include <queue>#include <cstdio>#include <bitset>#include <string>#include <vector>#include <iomanip>#include <cstring>#include <algorithm>#include <functional>#define PI acos(-1)#define eps 1e-8#define inf 0x3f3f3f3f#define debug(x) cout<<"---"<<x<<"---"<<endltypedef long long ll;using namespace std;struct ff{ int num; int vote;} a[150];bool cmp(ff a, ff b){ if (a.vote == b.vote) { return a.num < b.num; } return a.vote > b.vote;}int main(){ int t; cin >> t; while (t--) { memset(a, 0, sizeof(a)); int n; cin >> n; int xx; for (int i = 1; i <= n; i++) { cin >> xx; a[i].num = i; a[xx].vote++; } sort(a + 1, a + 1 + n, cmp); cout << a[1].num << endl; } return 0;}
阅读全文
0 0
- 【CUGBACM15级BC第20场 A】hdu 5123 who is the best?
- 【CUGBACM15级BC第15场 A】hdu 5083 Love
- 【CUGBACM15级BC第17场 A】hdu 5100 Chessboard
- 【CUGBACM15级BC第23场 A】hdu 5146 Sequence
- 【CUGBACM15级BC第8场 A】hdu 4989 Summary
- 【CUGBACM15级BC第31场 A】hdu 5178 pairs
- 【CUGBACM15级BC第1场 A】hdu 4857 逃生
- 【CUGBACM15级BC第20场 B】hdu 5124 lines
- BC who is the best?(HDU 5123)
- 【CUGBACM15级BC第13场 B】hdu 5063 Operation the Sequence
- 【CUGBACM15级BC第12场 A】【STL】hdu 5058 So easy
- 【CUGBACM15级BC第11场 A】hdu 5054 Alice and Bob
- 【CUGBACM15级BC第13场 A】hdu 5062 Beautiful Palindrome Number
- 【CUGBACM15级BC第18场 A】hdu 5104 Primes Problem
- 【CUGBACM15级BC第19场 A】hdu 5108 Alexandra and Prime Numbers
- 【CUGBACM15级BC第21场 A】hdu 5138 CET-6 test
- 【CUGBACM15级BC第22场 A】hdu 5142 NPY and FFT
- 【CUGBACM15级BC第24场 A】hdu 5150 Sum Sum Sum
- 2017.08.14总结
- 【黑科技】用树状数组解决区间修改查询问题
- CoordinatorLayout的layout_scrollFlags
- 前几天整理的Python小程序
- JS修改昵称
- 【CUGBACM15级BC第20场 A】hdu 5123 who is the best?
- ssh框架搭建出错
- Makefile :=和=区别
- 知识储备:02数组与字符串:判断元素出现与否及次数
- 用户分页多条件查询
- POJ2001 字典树
- POJ-1324:Holedox Moving(BFS+状态压缩+蛇蛇历险记)
- FCN和U-Net
- 经典试题一