Advertisement
dimon-torchila

Untitled

Jan 31st, 2022
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include<iostream>
  2. #include<map>
  3.  
  4. using namespace std;
  5.  
  6. void PrintMap(const map<int, int>& m)
  7. {
  8.     for (const auto& x : m)
  9.         cout << x.first << " -> " << x.second << endl;
  10. }
  11.  
  12. int main()
  13. {
  14.     map<int, int> counts;
  15.     int p;
  16.     cin >> p;
  17.     for (int i = 0; i < p; ++i)
  18.     {
  19.         int point;
  20.         cin >> point;
  21.         counts[point] = 0;
  22.     }
  23.     int pr;
  24.     cin >> pr;
  25.     for (int i = 0; i < pr; ++i)
  26.     {
  27.         int begin, end;
  28.         cin >> begin >> end;
  29.         for (auto& x : counts)
  30.             if (x.first >= begin && x.first <= end)
  31.                 x.second++;
  32.     }
  33.     PrintMap(counts);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement