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;
int main(){
int n;
cin >> n;
int A[n];
int B[n];
for(int i = 0; i < n; ++i) cin >> A[i];
for(int i = 0; i < n; ++i) cin >> B[i];
queue<int> Q;
int counter = 0;
for(int i = 0; i < n; ++i){
if(A[i] == B[i]) Q.push(i);
}
while(!Q.empty()){
int actPos = Q.front();
Q.pop();
if(A[actPos] == B[actPos]) counter++;
else continue;
if(actPos > 0){
if(A[actPos-1] != B[actPos] and A[actPos-1]<A[actPos]){
A[actPos-1] = B[actPos];
Q.push(actPos-1);
}
}
if(actPos < (n-1)){
if(A[actPos+1] != B[actPos] and A[actPos+1]<A[actPos]){
A[actPos+1] = B[actPos];
Q.push(actPos+1);
}
}
}
cout << counter<< endl;
return 0;
}
# | 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... |