fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int n,q,k;
  7. cin>>n>>q>>k;
  8.  
  9. vector<int> numbers(5*n, 0);
  10.  
  11. vector<int> startTimes(n), endTimes(n);
  12. vector<int> updates(5*n,0);
  13.  
  14. for(int i=0; i<n; i++){
  15. cin>>startTimes[i];
  16. updates[startTimes[i]]++;
  17. }
  18.  
  19. for(int i=0; i<n; i++){
  20. cin>>endTimes[i];
  21. updates[endTimes[i] + 1]--;
  22. }
  23.  
  24. vector<int> B(5*n,0);
  25.  
  26. for(int i=0; i<5*n; i++){
  27. updates[i+1] = updates[i+1] + updates[i];
  28. numbers[i] += updates[i];
  29.  
  30. if(numbers[i] >= k)B[i] = 1;
  31.  
  32. }
  33.  
  34. for(int i=0; i<5*n-1; i++){
  35. B[i+1] = B[i+1] + B[i];
  36. }
  37.  
  38. vector<pair<int,int>> queries(q);
  39.  
  40. for(auto& query: queries){
  41. cin>>query.first>>query.second;
  42.  
  43. int L = query.first, R = query.second;
  44.  
  45. if(B[R] - B[L - 1] >0)cout<<"YES"<<endl;
  46.  
  47. else cout<<"NO"<<endl;
  48. }
  49.  
  50.  
  51. return 0;
  52. }
Success #stdin #stdout 0.01s 5320KB
stdin
4 2 2
1 3 2 5
3 5 3 6
1 4
3 6
stdout
YES
YES