#include <iostream>
using namespace std;
int n;
int a[101010];
int b[101010];
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
cin >> b[i];
int last = 1;
int mx = 0;
int ans = 0;
for (int i = 1; i <= n; i++) {
if (a[i] > b[i]) {
if (mx == b[i])
ans += (i - last);
last = i + 1;
mx = 0;
continue;
}
mx = max(mx, a[i]);
continue;
}
if (mx == b[n])
ans += (n - last + 1);
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
17 ms |
828 KB |
Output is correct |
3 |
Correct |
53 ms |
1996 KB |
Output is correct |
4 |
Correct |
39 ms |
1360 KB |
Output is correct |
5 |
Correct |
117 ms |
3088 KB |
Output is correct |
6 |
Correct |
34 ms |
1344 KB |
Output is correct |
7 |
Correct |
32 ms |
1568 KB |
Output is correct |
8 |
Correct |
81 ms |
3012 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
304 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
448 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |