/**
* author: milos
* created: 16.04.2021 02:05:22
**/
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<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];
}
bool same = true;
for (int i = 0; i < n; i++) {
if (b[i] != b[0]) {
same = false;
}
}
if (same) {
vector<int> pos;
for (int i = 0; i < n; i++) {
if (a[i] == b[i]) {
pos.push_back(i);
}
}
for (int i : pos) {
for (int j = i + 1; j < n; j++) {
if (a[j] >= b[j]) {
break;
}
a[j] = a[i];
}
for (int j = i - 1; j >= 0; j--) {
if (a[j] >= b[j]) {
break;
}
a[j] = a[i];
}
}
int cnt = 0;
for (int i = 0; i < n; i++) {
if (a[i] == b[i]) {
cnt++;
}
}
cout << cnt << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
6 ms |
844 KB |
Output is correct |
3 |
Correct |
17 ms |
1996 KB |
Output is correct |
4 |
Correct |
14 ms |
1508 KB |
Output is correct |
5 |
Correct |
28 ms |
3148 KB |
Output is correct |
6 |
Correct |
15 ms |
1860 KB |
Output is correct |
7 |
Correct |
15 ms |
1612 KB |
Output is correct |
8 |
Correct |
25 ms |
3012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |