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(){
//12 poin :))
int n;
cin>>n;
vector<int> a(n+2),b(n+2),c(n+2);
for(int i=1; i<=n; i++){
cin>>a[i];
}
for(int i=1; i<=n; i++){
cin>>b[i];
}
int x=b[1];
for(int i=1; i<=n;i++){
if(c[i]==1)continue;
if(a[i]==x){
c[i]=1;
int j=i+1;
while(a[j]<=x&&j<=n){
a[j]=x;
c[j]=1;
j++;
}
j=i-1;
while(a[j]<=x&&1<=j){
if(c[j]==1)break;
a[j]=x;
c[j]=1;
j--;
}
}
}
int ans=0;
for(int i=1;i<=n;i++){
// cout<<a[i]<<" ";
if(a[i]==b[i])ans++;
}
cout<<ans<<"\n";
return 0;
}
/*
5
1 1 1 1 2
2 2 2 2 2
*/
# | 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... |