Naxocist

codecube_225

Mar 23rd, 2024
707
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void dbg_out() { cerr << endl; }
  5. template<typename Head, typename... Tail>
  6. void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
  7. #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
  8.  
  9. template<typename S, typename T> S amax(S &a, const T &b) { if(b > a) a = b; return a; }
  10. template<typename S, typename T> S amin(S &a, const T &b) { if(b < a) a = b; return a; }
  11.  
  12. #define all(x) x.begin(), x.end()
  13. #define allrev(x) x.rbegin(), x.rend()
  14. #define pb emplace_back
  15. #define sz(x) (int) (x).size()
  16. #define ln '\n'
  17. using ll = long long;
  18. using pi = pair<ll, ll>;
  19. using T = tuple<ll, ll, ll>;
  20. const ll INF = 2e9;
  21. const int mod = 1e9 + 7;
  22. const int N = 2e5 + 3;
  23.  
  24. void runcase() {
  25.     int n, k, q, sz = 0; cin >> n >> k >> q;
  26.     vector<int> cnt(k+1), dp(n+1), ar(n+1);
  27.  
  28.     for(int i=1; i<=n; ++i) cin >> ar[i];
  29.    
  30.     for(int l=1, r=0; l<=n; ++l) {
  31.         while(sz<k and r<=n) {
  32.             if(ar[++r] > k) continue ;
  33.             sz += ++cnt[ar[r]] == 1;
  34.         }
  35.         dp[l] = r;
  36.         if(ar[l] > k) continue ;
  37.         sz -= cnt[ar[l]]-- == 1;
  38.     }
  39.  
  40.     while(q--) { int l, r; cin >> l >> r; cout << (dp[l]<=r ? "YES" : "NO") << ln; }
  41.     return ;
  42. }
  43.  
  44. int32_t main() {
  45.     cin.tie(nullptr)->sync_with_stdio(0);
  46.     int TC = 1;
  47.     // cin >> TC;
  48.     while(TC--) runcase();
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment