This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |