fork download
  1. #include <iostream>
  2. #include <map>
  3. using namespace std;
  4.  
  5. int main() {
  6. long long n, m, p, q;
  7. cin >> m >> n;
  8.  
  9. map<long long, long long> arr;
  10. long long min;
  11. for (int i = 0; i < n; i++ ){
  12. long long t, tt;
  13. cin >> t >> tt;
  14. if (arr.count(t) == 0) {
  15. arr[t] = 1;
  16. } else {
  17. arr[t] += 1;
  18. }
  19. if (arr.count(tt) == 0) {
  20. arr[tt] = 1;
  21. } else {
  22. arr[tt] += 1;
  23. }
  24. }
  25. cin >> p >> q;
  26.  
  27. int res = 0;
  28. for(auto key : arr) {
  29. if (key.second <= q & key.second >= p) {
  30. res ++;
  31. }
  32. }
  33. cout << res;
  34. }
Success #stdin #stdout 0.01s 5504KB
stdin
2 1
1 2
1 2
stdout
2