This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define x first
#define y second
#define N 500015
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, q, mn[N];
pii arr[N];
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> arr[i].x;
for (int i = 1; i <= n; i++)
cin >> arr[i].y;
cin >> q;
for (int t = 0; t < q; t++){
int l, r; cin >> l >> r;
vector<pii> vt;
for (int i = l; i <= r; i++)
vt.push_back(arr[i]);
sort(vt.begin(), vt.end());
mn[vt.size()] = mn[(int)vt.size() - 1] = 1e9;
for (int i = (int)vt.size() - 2; i >= 0; i--)
mn[i] = min(vt[i + 1].y, mn[i + 1]);
int ans = 1;
for (int i = 0; i < (int)vt.size() - 1; i++)
if (vt[i].x < mn[i])
ans = 0;
cout << (ans ? "Yes\n" : "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... |