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;
#define ll long long
#define pll pair<long long, long long>
#define pii pair<int,int>
#define fi first
#define se second
const ll MOD=1e9+7;
void solve(){
int n;
cin >> n;
int ans=0;
ll robot[n];
ll building[n];
bool subtask2=true;
for(int i=0; i<n; i++){
cin >> robot[i];
}
for(int i=0; i<n; i++){
cin >> building[i];
if(subtask2 && i>0){
if(building[i]!=building[i-1]){
subtask2=false;
}
}
}
if(subtask2){
bool visited[n];
memset(visited,0,sizeof(visited));
for(int i=0; i<n; i++){
if(robot[i]==building[i] && !visited[i]){
visited[i]=true;
ans++;
ll idx=i+1;
while(robot[idx]<=robot[i] && idx<n){
visited[idx]=true;
ans++;
idx++;
}
idx=i-1;
while(robot[idx]<=robot[i] && idx>=0){
visited[idx]=true;
ans++;
idx--;
}
}
}
}
cout << ans << endl;
return;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int q=1;
for(int i=0; i<q; i++){
solve();
}
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... |