artemgf

Ползуны

Mar 16th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string>
  4. #include <math.h>
  5. #include <algorithm>
  6. #include <set>
  7. #include <map>
  8.  
  9. struct wheels
  10. {
  11.     int size;
  12.     int pairwheel;
  13. };
  14. using namespace std;
  15.  
  16. int main()
  17. {
  18.     map <int, wheels> wheel;
  19.     int n, prom;
  20.     wheels prom2;
  21.     prom2.size = 0;
  22.     prom2.pairwheel = 1;
  23.     set <int> size;
  24.  
  25.     cin >> n;
  26.     for (int i = 1; i <= n; i++)
  27.     {
  28.         cin >> prom;
  29.         if (wheel.find(prom) == wheel.end())
  30.         {
  31.             wheel.insert(pair <int, wheels>(prom, prom2));
  32.         }
  33.         else
  34.         {
  35.             wheel[prom].pairwheel = wheel[prom].pairwheel + 1;
  36.             if (wheel[prom].pairwheel == 4)
  37.             {
  38.                 wheel[prom].size = wheel[prom].size + 1;
  39.                 wheel[prom].pairwheel = 0;
  40.             }
  41.         }
  42.         size.insert(prom);
  43.     }
  44.  
  45.     int sum = 0;
  46.     for (auto i = size.begin(); i != size.end(); i++)
  47.     {
  48.         sum = sum + wheel[*i].size;
  49.     }
  50.        
  51.     cout << sum;
  52.  
  53.     _getch();
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment