#include <iostream>
using namespace std;
/*
3
1 2 3
2 2 2
4
10 1 9 1
10 9 10 9
*/
int main() {
int n; cin >> n;
int a[n], b[n];
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) cin >> b[i];
int res = 0;
int i = 0, ma = 0, j = 0;
for (; i < n; i++) {
if (a[i] > b[0]) {
if (ma == b[0]) res += i - j;
j = i + 1;
ma = 0;
} else {
ma = max(ma, a[i]);
}
}
if (ma == b[0]) res += i - j;
cout << res << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
11 ms |
448 KB |
Output is correct |
3 |
Correct |
35 ms |
1724 KB |
Output is correct |
4 |
Correct |
22 ms |
980 KB |
Output is correct |
5 |
Correct |
55 ms |
2964 KB |
Output is correct |
6 |
Correct |
22 ms |
980 KB |
Output is correct |
7 |
Correct |
25 ms |
980 KB |
Output is correct |
8 |
Correct |
53 ms |
980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 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 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |