fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main() {
  7. int n;
  8. cin >> n;
  9. vector<int> A;
  10. for (int i = 0; i < n; ++i){
  11. int a;
  12. cin >> a;
  13. A.push_back(a);
  14. }
  15. sort(A.begin(), A.begin() + n);
  16. for (int i = 0; i < n; ++i){
  17. cout << A[i] << " ";
  18. }
  19.  
  20. int count_max = 0;
  21. for (int i = 0; i < n; ++i){
  22. int m = 1;
  23. if (A[i] = A[i+1]){
  24. m = m + 1;
  25. if (m > count_max){
  26. count_max = m;
  27. }
  28. }
  29. else {
  30. break;
  31. }
  32. }
  33. cout << count_max << endl;
  34. return 0;
  35. }
Success #stdin #stdout 0s 5316KB
stdin
7 1 3 2 3 4 3 3 
stdout
1 2 3 3 3 3 4 2