Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n,m,i,j,a,maxi,v[102][102],f[1000000];
- int main()
- {
- cin>>n>>m;
- for(i=1;i<=n;i++)
- for(j=1;j<=m;j++)
- {
- cin>>v[i][j];
- f[v[i][j]]++;
- }
- for(i=1;i<=n;i++)
- for(j=1;j<=m;j++)
- {
- if(f[v[i][j]]>maxi)
- {
- maxi=f[v[i][j]];
- a=v[i][j];
- }
- else
- if(f[v[i][j]]==maxi&&v[i][j]>a)
- {
- maxi=f[v[i][j]];
- a=v[i][j];
- }
- }
- cout<<a;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement