JustOj 1386: 众数的数量

题目链接:http://oj.jxust.edu.cn/problem.php?id=1386

题目描述
qwn和Q伟N最近沉迷于Battle of Balls,天天翘课玩游戏。因为Q伟N太坑了,所以qwn决定弃游。于是乎到了木木店里买了n本书决定重返学霸之路,每本书价值ai(i<=n)。不过qwn被Battle of Balls这个游戏搞得智商下降,所以qwn想请你帮忙,问这n本书中价值相同的书籍最多有多少本?
输入

输入数据有多组,每组第一行输入一个整数n,第二行输入n个整数。n<=10000,题中所有数据不超过32位

输出

输出一个整数

样例输入
3
1 1 1
样例输出
3
 1 #include <iostream>
 2 #include <string>
 3 #include <cstring>
 4 #include <algorithm>
 5 #include <cmath>
 6 #include <map>
 7 #include <set>
 8 using namespace std;
 9 #define N 10010
10 #define ll long long
11  
12 ll a[N];
13 int main()
14 {
15     int n;
16     while(cin>>n){
17         for(int i=0;i<n;i++){
18             cin>>a[i];
19         }
20         sort(a,a+n);
21         int t=1,s=1;
22         for(int i=1;i<n;i++){
23             if(a[i]==a[i-1]){
24                 t++;
25                 if(t>s) s=t;
26             }
27             else t=1;
28         }
29         cout<<s<<endl;
30     }
31     return 0;
32 }

原文地址:https://www.cnblogs.com/wydxry/p/7475944.html