Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- void dbg_out() { cerr << endl; }
- template<typename Head, typename... Tail>
- void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
- #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
- template<typename S, typename T> S amax(S &a, const T &b) { if(b > a) a = b; return a; }
- template<typename S, typename T> S amin(S &a, const T &b) { if(b < a) a = b; return a; }
- #define all(x) x.begin(), x.end()
- #define allrev(x) x.rbegin(), x.rend()
- #define pb emplace_back
- #define sz(x) (int) (x).size()
- #define ln '\n'
- using ll = long long;
- using pi = pair<ll, ll>;
- using T = tuple<ll, ll, ll>;
- const ll INF = 2e9;
- const int mod = 1e9 + 7;
- const int N = 2e5 + 3;
- void runcase() {
- int n, k, q, sz = 0; cin >> n >> k >> q;
- vector<int> cnt(k+1), dp(n+1), ar(n+1);
- for(int i=1; i<=n; ++i) cin >> ar[i];
- for(int l=1, r=0; l<=n; ++l) {
- while(sz<k and r<=n) {
- if(ar[++r] > k) continue ;
- sz += ++cnt[ar[r]] == 1;
- }
- dp[l] = r;
- if(ar[l] > k) continue ;
- sz -= cnt[ar[l]]-- == 1;
- }
- while(q--) { int l, r; cin >> l >> r; cout << (dp[l]<=r ? "YES" : "NO") << ln; }
- return ;
- }
- int32_t main() {
- cin.tie(nullptr)->sync_with_stdio(0);
- int TC = 1;
- // cin >> TC;
- while(TC--) runcase();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment