fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, m;
  6. cin >> n >> m;
  7.  
  8. int* contar = new int[n];
  9.  
  10. for (int i = 0; i < n; ++i) {
  11. int producto_id;
  12. cin >> producto_id;
  13. contar[producto_id]++;
  14. }
  15.  
  16. for (int i = 0; i < n; ++i) {
  17. if (contar[i] >= m) {
  18. cout << i << " " << contar[i] << endl;
  19. }
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5276KB
stdin
9 3
5
9
1
9
1
9
1
1
0
stdout
1 4