//Subtask 2
#include<bits/stdc++.h>
using namespace std;
int a[100005], b[100005], firstval[100005], lastval[100005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n; cin>>n;
for(int i = 1; i <= n; i++) cin>>a[i];
for(int i = 1; i <= n; i++) cin>>b[i];
int target = b[1];
for(int i = 1; i <= n; i++){
if(a[i] >= target) firstval[i] = a[i];
else firstval[i] = firstval[i-1];
}
for(int i = n; i >= 1; i--){
if(a[i] >= target) lastval[i] = a[i];
else lastval[i] = lastval[i+1];
}
int ans = 0;
for(int i = 1; i <= n; i++) if(lastval[i] == target || firstval[i] == target) ans++;
cout<<ans;
}
# | 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... |