이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
#define ins insert
#define arr3 array<int, 3>
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n; cin>>n;
vector<int> a(n + 1), b(n + 1);
for (int i = 1; i <= n; i++) cin>>a[i];
for (int i = 1; i <= n; i++) cin>>b[i];
int q; cin>>q;
while (q--){
int l, r; cin>>l>>r;
vector<int> x;
set<pii> st;
for (int i = l; i <= r; i++){
x.pb(i);
st.ins({a[i], i});
}
auto cmp = [&](int i, int j){
return b[i] > b[j];
};
sort(x.begin(), x.end(), cmp);
bool ind = 1;
for (int i: x){
auto it = st.find({a[i], i});
bool k = (it != st.end());
if (k) st.erase(it);
it = st.lower_bound({b[i], 0});
if (it == st.end()){
ind = 0;
break;
}
st.erase(it);
if (k) st.ins({a[i], i});
}
cout<<((ind) ? "Yes" : "No")<<"\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... |