이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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];
vector<bool> visited(n);
vector<bool> ending(n);
vector<bool> starting(n);
ending[0] = 1;
FORNEG(i, n-1, 0){
if (visited[i] == 0) starting[i] = 1;
if (vals[i-1] >= req[i]) visited[i] = 1, visited[i-1] = 1;
else ending[i] = 1;
}
vector<ll> pref(n);
pref[0] = visited[0];
FOR(i,1,n) pref[i] = pref[i-1] + visited[i];
ll q;
cin >> q;
FOR(i,0,q){
ll a,b;
cin >> a >> b;
a--;b--;
ll sus = pref[b] - pref[a] + visited[a];
if (sus == (b-a+1) && !ending[b] && !starting[a]) cout << "Yes" << "\n";
else cout << "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... |