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>
#define all(v) ((v).begin(),(v).end())
typedef long long ll;
using namespace std;
const int mod = 1e9 + 7;
const int mxN = 2e6 + 1;
int a[mxN];
int b[mxN];
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin >>n;
for(int i =0;i < n;i++){
cin >>a[i];
}
for(int i = 0;i < n;i++){
cin >>b[i];
}
for(int i = 0;i < n;i++){
if(a[i] == b[i]){
for(int j = i + 1;j < n;j++){
if(a[j] < b[i]){
a[j] = b[i];
}else
break;
}
for(int j = i - 1;j >= 0;j--){
if(a[j] < b[i]){
a[j] = b[i];
}else
break;
}
}
}
int ans = 0;
for(int i =0;i < n;i++){
if(a[i] == b[i])
ans++;
}
cout <<ans;
}
// nice
# | 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... |