Advertisement
srtgguy

Untitled

May 23rd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n, x, k = 0;
  9.     cin >> n;
  10.     map<int, int> values;
  11.     for (int i = 0; i < n; i++)
  12.     {
  13.         cin >> x;
  14.         if (values.find(x) != values.end())
  15.         {
  16.             values.at(x) += 1;
  17.         }
  18.         if (values.find(x) == values.end())
  19.         {
  20.             values.insert(pair<int, int> (x, 1));
  21.         }
  22.         if (values[x] == 4)
  23.         {
  24.             k += 1;
  25.             values.at(x) = 0;
  26.         }
  27.     }
  28.     cout << k << endl;
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement