# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1060247 | anango | Gift Exchange (JOI24_ho_t4) | C++17 | 2544 ms | 10188 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>
#define int long long
using namespace std;
int INF = 1LL<<30;
signed main() {
int local = 1;
if (local) {
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n; cin >> n;
vector<int> ar(n); for (int i=0; i<n; i++) cin >> ar[i];
vector<int> br(n); for (int i=0; i<n; i++) cin >> br[i];
/*for (int i=0; i<n; i++) {
ar[i]--; br[i]--;
}*/
int q; cin >> q;
while (q--) {
int l,r; cin >> l >> r; l--; r--;
vector<pair<int,int>> endpoints;
for (int i=l; i<=r; i++) {
endpoints.push_back({ar[i],-(i+1)});
endpoints.push_back({br[i],(i+1)});
}
sort(endpoints.begin(), endpoints.end());
int fail = 0;
int ct = 0;
for (int i=0; i<endpoints.size(); i++) {
if (endpoints[i].second<0) ct--;
else ct++;
//cout << i <<" " << endpoints[i].first <<" " << endpoints[i].second <<" " << ct << endl;
if (ct==0 && i!=0 && endpoints[i].second+endpoints[i-1].second==0) {
fail=1;
}
}
if (fail) {
cout << "No" << endl;
}
else {
cout << "Yes" << endl;
}
}
}
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... |