fork download
  1. #include<bits/stdc++.h>
  2. #define IO ios_base::sync_with_stdio(),cin.tie(0),cout.tie(0) ;
  3. #define ll long long
  4. using namespace std;
  5. const int N = 2e5 + 4 ;
  6. int n , k , l , r , q ;
  7. ll pre[N] , good[N] ;
  8. int main() {
  9. IO ;
  10. cin>>n>>k>>q ;
  11. for(int i=1 ; i <= n ; i++)
  12. {
  13. cin>>l>>r ;
  14. pre[l]++ ;
  15. pre[r+1]-- ;
  16. }
  17. for(int i = 1 ; i <= 200000 ; i++)
  18. {
  19. pre[i] += pre[i-1] ;
  20. if(pre[i] >= k)
  21. good[i] = 1 ;
  22. }
  23. for(int i = 1 ; i <= 200000 ; i++)
  24. good[i] += good[i-1] ;
  25. while (q--)
  26. {
  27. cin>>l>>r ;
  28. cout<<good[r] - good[l-1]<<'\n' ;
  29. }
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 6676KB
stdin
Standard input is empty
stdout
Standard output is empty