#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
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
468 KB |
Output is correct |
3 |
Correct |
14 ms |
1044 KB |
Output is correct |
4 |
Correct |
11 ms |
1104 KB |
Output is correct |
5 |
Correct |
21 ms |
1020 KB |
Output is correct |
6 |
Correct |
10 ms |
1108 KB |
Output is correct |
7 |
Correct |
10 ms |
1108 KB |
Output is correct |
8 |
Correct |
18 ms |
1108 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 |
1 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 |
- |