Advertisement
raresdragos2006

Untitled

Jan 23rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int n,m,i,j,a,maxi,v[102][102],f[1000000];
  4. int main()
  5. {
  6. cin>>n>>m;
  7. for(i=1;i<=n;i++)
  8. for(j=1;j<=m;j++)
  9. {
  10. cin>>v[i][j];
  11. f[v[i][j]]++;
  12. }
  13. for(i=1;i<=n;i++)
  14. for(j=1;j<=m;j++)
  15. {
  16. if(f[v[i][j]]>maxi)
  17. {
  18. maxi=f[v[i][j]];
  19. a=v[i][j];
  20. }
  21. else
  22. if(f[v[i][j]]==maxi&&v[i][j]>a)
  23. {
  24. maxi=f[v[i][j]];
  25. a=v[i][j];
  26. }
  27. }
  28. cout<<a;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement