# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1032431 | Andrey | Gift Exchange (JOI24_ho_t4) | C++14 | 2590 ms | 4692 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
bool check(vector<pair<int,int>> haha) {
sort(haha.begin(),haha.end());
vector<int> su(haha.size()+1,INT_MAX);
for(int i = haha.size()-1; i >= 0; i--) {
su[i] = min(su[i+1],haha[i].second);
}
for(int i = 0; i < haha.size(); i++) {
if((i == 0 || haha[i-1].first < haha[i].second) && su[i+1] > haha[i].first) {
return false;
}
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,q,l,r;
cin >> n;
vector<int> a(n+1);
vector<int> b(n+1);
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
for(int i = 1; i <= n; i++) {
cin >> b[i];
}
cin >> q;
for(int i = 0; i < q; i++) {
cin >> l >> r;
vector<pair<int,int>> haha(0);
for(int j = l; j <= r; j++) {
haha.push_back({a[j],b[j]});
}
if(check(haha)) {
cout << "Yes\n";
}
else {
cout << "No\n";
}
}
return 0;
}
Compilation message (stderr)
# | 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... |