fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define pb push_back
  5. #define all(a) a.begin(), a.end()
  6. #define rep(i, x, n) for (int i = x; i <= n; ++i)
  7. #define inp(a) freopen(a".inp", "r", stdin), freopen(a".out", "w", stdout)
  8.  
  9.  
  10. int n, k;
  11. int main(){
  12. cin.tie(0) -> sync_with_stdio(0);
  13. inp("hopqua");
  14.  
  15. cin >>n >>k;
  16.  
  17. vector<int> a(n);
  18.  
  19. for (int &x: a) cin >>x;
  20.  
  21. sort(all(a));
  22. a.pb(1e9 + 1); //break point
  23.  
  24. int cnt = 0, value = 0;
  25. int prev = -1, c = 0;
  26.  
  27. for (int x: a) if (x == prev) ++c;
  28. else {
  29. if (c > cnt){
  30. cnt = c; value = prev;
  31. }
  32.  
  33. prev = x; c = 1;
  34. }
  35.  
  36. cout <<cnt <<' ' <<value;
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
Standard output is empty