#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
using namespace std;
int n, h[100010], t[100010];
bool vis[100010];
int main(){
cin >> n;
for(int i=1; i<=n; i++){
cin >> h[i];
}
vector<int> tmp;
for(int i=1; i<=n; i++){
cin >> t[i];
if(t[i]==h[i]){
tmp.pb(i);
}
}
int ans=0;
for(auto i : tmp){
// cout << "i " << i << endl;
vis[i]=1;
ans++;
int l=i, r=i;
while(l-1>=1 && !vis[l-1]){
l--;
// cout << l << endl;
vis[l]=1;
if(h[l]>=h[i]) break;
ans++;
}
while(r+1<=n && !vis[r+1]){
r++;
// cout << r << endl;
vis[r]=1;
if(h[r]>=h[i]) break;
ans++;
}
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
12 ms |
468 KB |
Output is correct |
3 |
Correct |
37 ms |
1988 KB |
Output is correct |
4 |
Correct |
22 ms |
1484 KB |
Output is correct |
5 |
Correct |
60 ms |
3148 KB |
Output is correct |
6 |
Correct |
22 ms |
1824 KB |
Output is correct |
7 |
Correct |
28 ms |
1740 KB |
Output is correct |
8 |
Correct |
72 ms |
2940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |