# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1032428 | Andrey | Gift Exchange (JOI24_ho_t4) | C++14 | 2538 ms | 4056 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<bool> wow(haha.size()+1);
for(int i = 1; i < haha.size(); i++) {
if(haha[i-1].first > haha[i].second) {
wow[i] = 1;
}
}
for(int i = 0; i < haha.size(); i++) {
if(!wow[i] && !wow[i+1]) {
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... |