#include <bits/stdc++.h>
using namespace std;
const int nx=1e5+5;
int n, q, a[nx], b[nx], l, r, mx;
vector<int> mp, v;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=1; i<=n; i++) cin>>a[i];
for (int i=1; i<=n; i++) cin>>b[i];
cin>>q;
while (q--)
{
cin>>l>>r;
mp.clear();
v.clear();
for (int i=l; i<=r; i++) mp.push_back(a[i]), mp.push_back(b[i]);
sort(mp.begin(), mp.end());
for (int i=l; i<=r; i++) v.push_back(upper_bound(mp.begin(), mp.end(), a[i])-mp.begin());
sort(v.begin(), v.end());
int f=0;
for (int i=0; i<(r-l); i++)
{
if (v[i]==2*(i+1))
{
f=1;
cout<<"No\n";
break;
}
}
if (!f) cout<<"Yes\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |