1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; map<int , int > a; int n,b,ma,maX; int main() { cin>>n; while(n--) { cin>>b; a[b]++; } map<int , int > ::iterator it; for(it=a.begin();it!=a.end();++it) if(it->second>ma)ma=it->second,maX=it->first; cout<<maX<<"\n"<<ma; return 0; }
Pascal :
var n,m,i,max,maxs,x:longint;a:array[1..70000] of longint; begin readln(n); fillchar(a,sizeof(a),0); m:=0; for i:=1 to n do begin readln(x); if x>m then m:=x; a[x]:=a[x]+1; end; max:=0; for i:=1 to m do if a[i]>max then begin max:=a[i];maxs:=i;end; writeln(maxs); writeln(max); end.
- 1
Information
- ID
- 628
- Time
- 3000ms
- Memory
- 128MiB
- Difficulty
- 10
- Tags
- # Submissions
- 1
- Accepted
- 1
- Uploaded By