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>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin >> n;
vector<ll> vals(n), req(n);
FOR(i,0,n) cin >> vals[i];
FOR(i,0,n) cin >> req[i];
ll q;
cin >> q;
FOR(i,0,q){
ll a,b;
cin >> a >> b;
a--;b--;
vector<ll> idk, idk2;
bool flag = false;
FOR(j,a,b+1){
idk.push_back(vals[j]);
idk2.push_back(req[j]);
}
sort(idk.begin(), idk.end());
sort(idk2.begin(), idk2.end());
ll l = idk.size()-1;
vector<bool> visited(idk.size());
FORNEG(j, idk.size()-1, 0){
if (idk2[j] <= idk[j-1]) visited[j] = 1, visited[j-1] = 1;
}
ll sumz = 0;
for (auto i : visited) sumz += i;
if (sumz==idk.size()) cout << "Yes" << "\n";
else cout << "No" << "\n";
}
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:42:11: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | if (sumz==idk.size()) cout << "Yes" << "\n";
| ~~~~^~~~~~~~~~~~
Main.cpp:25:8: warning: unused variable 'flag' [-Wunused-variable]
25 | bool flag = false;
| ^~~~
Main.cpp:32:6: warning: unused variable 'l' [-Wunused-variable]
32 | ll l = idk.size()-1;
| ^
# | 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... |